【发布时间】:2020-11-29 01:18:43
【问题描述】:
在将函数ConfigureServices 的签名更改为异步后(最初它只是一个无效的同步函数,应用程序运行良好),我收到以下错误:
找不到所需的服务。请通过在应用程序启动代码中对
ConfigureServices(...)的调用中调用IServiceCollection.AddAuthorization添加所有必需的服务。
下面是我的ConfigureServices函数的代码。
// This method gets called by the runtime. Use this method to add services to the container.
public async Task ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
// Create the necessary Cosmos DB infrastructure
await CreateDatabaseAsync();
await CreateContainerAsync();
}
ConfigureServices 在运行时自动调用。
【问题讨论】:
-
有可能使用 IHostedService stackoverflow.com/a/64118183/940182
标签: c# azure asp.net-core asynchronous azure-webapps