每當我將 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條經驗 獲得超6個贊
我能夠重現同樣的問題,但我得到了同樣的錯誤,要解決這個問題,請嘗試以下操作:
打開您的 *.csproj 文件,找到Property group tag
并將其更新為:
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName> </PropertyGroup>
嘗試看看是否有幫助。
- 1 回答
- 0 關注
- 110 瀏覽
添加回答
舉報
0/150
提交
取消