Avoid azure app config for local environment
This commit is contained in:
@@ -17,22 +17,27 @@ namespace Core.Thalos.Adapters.Helpers
|
||||
|
||||
public static AuthSettings GetAuthSettings(WebApplicationBuilder builder, string appConfigLabel)
|
||||
{
|
||||
builder.Configuration.AddAzureAppConfiguration(options =>
|
||||
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
|
||||
|
||||
if (environment != "Local")
|
||||
{
|
||||
var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value;
|
||||
|
||||
if (string.IsNullOrEmpty(endpoint))
|
||||
throw new ArgumentException("The app configuration is missing");
|
||||
|
||||
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
|
||||
.Select(KeyFilter.Any, "thalos_common")
|
||||
.Select(KeyFilter.Any, appConfigLabel);
|
||||
|
||||
options.ConfigureKeyVault(keyVaultOptions =>
|
||||
builder.Configuration.AddAzureAppConfiguration(options =>
|
||||
{
|
||||
keyVaultOptions.SetCredential(new DefaultAzureCredential());
|
||||
var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value;
|
||||
|
||||
if (string.IsNullOrEmpty(endpoint))
|
||||
throw new ArgumentException("The app configuration is missing");
|
||||
|
||||
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
|
||||
.Select(KeyFilter.Any, "thalos_common")
|
||||
.Select(KeyFilter.Any, appConfigLabel);
|
||||
|
||||
options.ConfigureKeyVault(keyVaultOptions =>
|
||||
{
|
||||
keyVaultOptions.SetCredential(new DefaultAzureCredential());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return new AuthSettings
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user