Created
August 15, 2020 12:31
-
-
Save jarig/27edf484aa17f0f9c672bba9b85d598b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((context, config) => | |
{ | |
var builtConfig = config.Build(); | |
var userAssignedId = builtConfig["UserAssignedId"]; | |
AzureServiceTokenProvider azureServiceTokenProvider; | |
if (string.IsNullOrEmpty(userAssignedId)) | |
{ | |
azureServiceTokenProvider = new AzureServiceTokenProvider(); | |
} | |
else | |
{ | |
azureServiceTokenProvider = new AzureServiceTokenProvider($"RunAs=App;AppId={userAssignedId}"); | |
} | |
var keyVaultClient = new KeyVaultClient( | |
new KeyVaultClient.AuthenticationCallback( | |
azureServiceTokenProvider.KeyVaultTokenCallback)); | |
config.AddAzureKeyVault( | |
$"https://{builtConfig["KeyVaultName"]}.vault.azure.net/", | |
keyVaultClient, | |
new DefaultKeyVaultSecretManager()); | |
}) | |
.UseStartup<Startup>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment