I am setting up a .Net Standard app to get secrets from an Azure secret vault. This is running on my local machine, so any Environment reference is to the local environment on my machine.
public string GetSecret()
{
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ExcludeAzureCliCredential = true, ExcludeAzurePowerShellCredential = true, ExcludeInteractiveBrowserCredential = true, ExcludeManagedIdentityCredential = true, ExcludeSharedTokenCacheCredential = true, ExcludeVisualStudioCodeCredential = true, ExcludeVisualStudioCredential = true });
secretClient = new SecretClient(new Uri(BASESECRETURI),credential);
KeyVaultSecret secret = secretClient.GetSecret(_secretRequest.SecretName);
return secret.Value;
}
I have set up my environment variables, both user and system:
Yet when I run it, it pulls the environment values from...I don't know where.
If I programmatically set the values on run (Environment.SetEnvironmentVariable("AZURE_TENANT_ID","89aa..."), etc.), before it get the DefaultAzureCredential, it is set correctly!
Does anyone know where it is getting the values, or how I can set the environment variables correctly so they are fetched by DefaultAzureCredential()?