Add "AzureRedisConnectionString" environment variable and add a connectionString condition when "AzureRedisEnabled" environment variable is true
This commit is contained in:
parent
cd790f276f
commit
db7d2a3ff3
@ -61,7 +61,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
||||
services.AddSingleton<ConnectionMultiplexer>(sp =>
|
||||
{
|
||||
var settings = sp.GetRequiredService<IOptions<BasketSettings>>().Value;
|
||||
var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true);
|
||||
if (Configuration.GetValue<bool>("AzureRedisEnabled"))
|
||||
{
|
||||
settings.ConnectionString = Configuration["AzureRedisConnectionString"];
|
||||
}
|
||||
|
||||
ConfigurationOptions configuration = ConfigurationOptions.Parse(settings.ConnectionString, true);
|
||||
configuration.ResolveDns = true;
|
||||
|
||||
return ConnectionMultiplexer.Connect(configuration);
|
||||
|
@ -8,5 +8,7 @@
|
||||
}
|
||||
},
|
||||
"IdentityUrl": "http://localhost:5105",
|
||||
"ConnectionString": "eshoponazure.redis.cache.windows.net:6379,password=I9t4YmytcxvAjThGz98oUbfcI0Zcu7sIB2nhmmDxjVo=,ssl=false,abortConnect=false"
|
||||
"ConnectionString": "127.0.0.1",
|
||||
"AzureRedisConnectionString": "eshoponazure.redis.cache.windows.net:6379,password=I9t4YmytcxvAjThGz98oUbfcI0Zcu7sIB2nhmmDxjVo=,ssl=false,abortConnect=false",
|
||||
"AzureRedisEnabled": "true"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user