前置條件
- 安裝docker與dapr: 手把手教你學Dapr - 3. 使用Dapr運行第一個.Net程序
- 安裝k8s
dapr 自托管模式運行
新建一個webapi無權限項目
launchSettings.json中applicationUrl端口改成5001,如下:
"applicationUrl": "http://localhost:5001"
//WeatherForecastController.cs更改如下
using Microsoft.AspNetCore.Mvc;namespace backend.Controllers
{[ApiController][Route("[controller]")]public class WeatherForecastController : ControllerBase{private static readonly string[] Summaries = new[]{"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"};private readonly ILogger<WeatherForecastController> _logger;public WeatherForecastController(ILogger<WeatherForecastController> logger){_logger = logger;}[HttpGet(Name = "GetWeatherForecast