Skip to content

Commit

Permalink
#141 wi-profile: Configuration for Workload Identity (#164)
Browse files Browse the repository at this point in the history
* wi-profile: giving access to platform keyvault

* string interpolation removed
  • Loading branch information
khanrn authored Jul 11, 2024
1 parent 3e7486b commit 6d7b035
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Altinn.Profile/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,16 @@ async Task ConnectToKeyVaultAndSetApplicationInsights(ConfigurationManager confi
{
KeyVaultSettings keyVaultSettings = new();
config.GetSection("kvSetting").Bind(keyVaultSettings);
if (!string.IsNullOrEmpty(keyVaultSettings.ClientId) &&
!string.IsNullOrEmpty(keyVaultSettings.TenantId) &&
!string.IsNullOrEmpty(keyVaultSettings.ClientSecret) &&
!string.IsNullOrEmpty(keyVaultSettings.SecretUri))
if (!string.IsNullOrEmpty(keyVaultSettings.SecretUri))
{
logger.LogInformation("Program // Configure key vault client // App");
Environment.SetEnvironmentVariable("AZURE_CLIENT_ID", keyVaultSettings.ClientId);
Environment.SetEnvironmentVariable("AZURE_CLIENT_SECRET", keyVaultSettings.ClientSecret);
Environment.SetEnvironmentVariable("AZURE_TENANT_ID", keyVaultSettings.TenantId);
var azureCredentials = new DefaultAzureCredential();
logger.LogInformation("Program // Set app insights connection string // App");

config.AddAzureKeyVault(new Uri(keyVaultSettings.SecretUri), azureCredentials);
DefaultAzureCredential azureCredentials = new();

SecretClient client = new(new Uri(keyVaultSettings.SecretUri), azureCredentials);

config.AddAzureKeyVault(new Uri(keyVaultSettings.SecretUri), azureCredentials);

try
{
KeyVaultSecret keyVaultSecret = await client.GetSecretAsync(VaultApplicationInsightsKey);
Expand Down

0 comments on commit 6d7b035

Please sign in to comment.