每當(dāng)我將 Azure Key Vault 應(yīng)用配置添加到我的 program.cs 文件時(shí),我的 Web 應(yīng)用都會(huì)遇到啟動(dòng)錯(cuò)誤 500.30。在本地,我可以訪問保險(xiǎn)庫(kù)并對(duì)其進(jìn)行了測(cè)試,但一旦發(fā)布,我就會(huì)收到錯(cuò)誤消息。我已經(jīng)嘗試將系統(tǒng)和用戶身份添加到我的 Web 應(yīng)用程序,并通過 Azure 訪問控制和訪問策略授予它權(quán)限。我也已授予該應(yīng)用程序訪問整個(gè)資源的權(quán)限。我已經(jīng)注釋掉了這部分并且應(yīng)用程序運(yùn)行了,這就是為什么我將錯(cuò)誤歸因于密鑰庫(kù)。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/";我希望能夠訪問密鑰庫(kù)。該應(yīng)用程序在發(fā)布時(shí)拋出 HTTP 錯(cuò)誤 500.30 - ANCM 進(jìn)程內(nèi)啟動(dòng)失敗。更新:更改為 OutOfProcess 后,我現(xiàn)在收到錯(cuò)誤 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貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
我能夠重現(xiàn)同樣的問題,但我得到了同樣的錯(cuò)誤,要解決這個(gè)問題,請(qǐng)嘗試以下操作:
打開您的 *.csproj 文件,找到Property group tag
并將其更新為:
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName> </PropertyGroup>
嘗試看看是否有幫助。
- 1 回答
- 0 關(guān)注
- 119 瀏覽
添加回答
舉報(bào)
0/150
提交
取消