我正试图将我的蚊帐核心应用与Keyvault挂钩。 在一个支持身份认同的新 a器上,一切都行得通,但这一申请是在一个不支持身份的经典的斜体上进行的。 我把系统环境变星星星星星号放在了其他可分的网基应用中,关键标志已经使用并且正在完美地运作。
检查我的排外记录,我每次都有以下例外。
Azure.Identity.CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials EnvironmentCredential authentication unavailable. Environment variables are not fully configured ManagedIdentityCredential authentication unavailable, the requested identity has not been assigned to this resource.
我在开始时使用以下法典:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseApplicationInsights(ConfigurationManager.AppSettings["applicationInsightsInstrumentationKey"])
.ConfigureKestrel(options => options.AddServerHeader = false)
.UseIISIntegration()
.ConfigureAppConfiguration((context, config) =>
{
var vaultName = ConfigurationManager.AppSettings["VaultName"];
if (!string.IsNullOrEmpty(vaultName))
{
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(
new KeyVaultClient.AuthenticationCallback(
azureServiceTokenProvider.KeyVaultTokenCallback));
config.AddAzureKeyVault(
$"https://{vaultName}.vault.azure.net/",
keyVaultClient,
new DefaultKeyVaultSecretManager());
}
})
.UseStartup<Startup>();
网上。 没收下列物品:
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false"/>
</configSections>
<configBuilders>
<builders>
<add name="AzureKeyVault" vaultName="<#= this.VaultName #>" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral" vaultUri="https://<#= this.VaultName #>.vault.azure.net" />
</builders>
</configBuilders>
<connectionStrings configBuilders="AzureKeyVault">
<add name="ConnectionString" connectionString="" providerName="System.Data.SqlClient"/>
</connectionStrings>