新建webapi项目
- 建项目时取消https支持,勾选docker支持,
- Program.cs中注释下面语句,这样部署后才能访问Swagger
// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
- 添加Dapr.Client与Dapr.AspNetCore两个nuget包
- 修改Program.cs文件,增加dapr sdk支持
- 修改WeatherForecastController.cs文件
using Dapr;
using Dapr.Client;
using Microsoft.AspNetCore.Mvc;
namespace backend.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
priva