update variable

This commit is contained in:
zedy
2023-02-17 11:10:10 +08:00
parent 7e99523594
commit 3e0ca9869d
2 changed files with 8 additions and 7 deletions

View File

@@ -23,10 +23,14 @@ var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddConsole(); builder.Logging.AddConsole();
var azdTemplate= builder.Configuration["AZD_TEMPLATE"]; var env = builder.Configuration["Environment"];
if (azdTemplate == "enable"){ if (env == "Local"){
// Configure SQL Server (Azd template) // Configure SQL Server (local)
Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services);
}
else{
// Configure SQL Server (prod)
var credential = new ChainedTokenCredential(new AzureDeveloperCliCredential(), new DefaultAzureCredential()); var credential = new ChainedTokenCredential(new AzureDeveloperCliCredential(), new DefaultAzureCredential());
builder.Configuration.AddAzureKeyVault(new Uri(builder.Configuration["AZURE_KEY_VAULT_ENDPOINT"]), credential); builder.Configuration.AddAzureKeyVault(new Uri(builder.Configuration["AZURE_KEY_VAULT_ENDPOINT"]), credential);
builder.Services.AddDbContext<CatalogContext>(c => builder.Services.AddDbContext<CatalogContext>(c =>
@@ -40,10 +44,6 @@ if (azdTemplate == "enable"){
options.UseSqlServer(connectionString, sqlOptions => sqlOptions.EnableRetryOnFailure()); options.UseSqlServer(connectionString, sqlOptions => sqlOptions.EnableRetryOnFailure());
}); });
} }
else{
// Configure SQL Server (Locally)
Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services);
}
builder.Services.AddCookieSettings(); builder.Services.AddCookieSettings();

View File

@@ -8,6 +8,7 @@
"IdentityConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;" "IdentityConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;"
}, },
"CatalogBaseUrl": "", "CatalogBaseUrl": "",
"Environment": "Local",
"Logging": { "Logging": {
"IncludeScopes": false, "IncludeScopes": false,
"LogLevel": { "LogLevel": {