每当我将 Azure Key Vault 应用配置添加到我的 program.cs 文件时,我的 Web 应用都会遇到启动错误 500.30。在本地,我可以访问保险库并对其进行了测试,但一旦发布,我就会收到错误消息。我已经尝试将系统和用户身份添加到我的 Web 应用程序,并通过 Azure 访问控制和访问策略授予它权限。我也已授予该应用程序访问整个资源的权限。我已经注释掉了这部分并且应用程序运行了,这就是为什么我将错误归因于密钥库。public static IWebHost CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args)// this gets commented out to run properly .ConfigureAppConfiguration((ctx, builder) => { var keyVaultEndpoint = GetKeyVaultEndpoint(); if (!string.IsNullOrEmpty(keyVaultEndpoint)) { var azureServiceTokenProvider = new AzureServiceTokenProvider(); var keyVaultClient = new KeyVaultClient( new KeyVaultClient.AuthenticationCallback( azureServiceTokenProvider.KeyVaultTokenCallback)); builder.AddAzureKeyVault( keyVaultEndpoint, keyVaultClient, new DefaultKeyVaultSecretManager()); } } ) // until here .UseStartup<Startup>() .Build();private static string GetKeyVaultEndpoint() => "https://<vault name>.vault.azure.net/";我希望能够访问密钥库。该应用程序在发布时抛出 HTTP 错误 500.30 - ANCM 进程内启动失败。更新:更改为 OutOfProcess 后,我现在收到错误 502.5。带有以下消息:Unhandled Exception: Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException: Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/<MyId>. Exception Message: Tried the following 3 methods to get an access token, but none of them worked.Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/<MyId>. Exception Message: Tried to get token using Managed Service Identity. Access token could not be acquired. Failed after 5 retries. MSI ResponseCode: BadRequest, Response:
1 回答
ibeautiful
TA贡献1993条经验 获得超5个赞
我能够重现同样的问题,但我得到了同样的错误,要解决这个问题,请尝试以下操作:
打开您的 *.csproj 文件,找到Property group tag
并将其更新为:
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName> </PropertyGroup>
尝试看看是否有帮助。
- 1 回答
- 0 关注
- 88 浏览
添加回答
举报
0/150
提交
取消