|
1 | | -using System.Net.Mime; |
| 1 | +using System.Net.Mime; |
2 | 2 | using Ardalis.ListStartupServices; |
3 | | -using Azure.Identity; |
4 | 3 | using BlazorAdmin; |
5 | 4 | using BlazorAdmin.Services; |
6 | 5 | using Blazored.LocalStorage; |
|
18 | 17 | using Microsoft.eShopWeb.Web.Configuration; |
19 | 18 | using Microsoft.eShopWeb.Web.HealthChecks; |
20 | 19 | using Microsoft.Extensions.Diagnostics.HealthChecks; |
| 20 | +using Microsoft.FeatureManagement; |
21 | 21 |
|
22 | 22 | var builder = WebApplication.CreateBuilder(args); |
| 23 | + |
| 24 | +builder.Configuration.AddAzureAppConfiguration(options => |
| 25 | +{ |
| 26 | + var connection = builder.Configuration.GetConnectionString("AppConfig"); |
| 27 | + |
| 28 | + options.Connect(connection) |
| 29 | + .UseFeatureFlags() |
| 30 | + .ConfigureRefresh(refresh => |
| 31 | + { |
| 32 | + // Este registra la flag principal y habilita refrescar toda la configuración |
| 33 | + refresh.Register("EnableShoppingCart", refreshAll: true) |
| 34 | + .SetCacheExpiration(TimeSpan.FromSeconds(10)); // refresca cada 10 segundos |
| 35 | + }); |
| 36 | +}); |
| 37 | + |
| 38 | + |
| 39 | +builder.Services.AddAzureAppConfiguration(); |
| 40 | +builder.Services.AddFeatureManagement(); |
| 41 | + |
23 | 42 | builder.Logging.AddConsole(); |
24 | 43 |
|
25 | | -if (builder.Environment.IsDevelopment() || builder.Environment.EnvironmentName == "Docker"){ |
| 44 | +if (builder.Environment.IsDevelopment() || builder.Environment.EnvironmentName == "Docker") |
| 45 | +{ |
26 | 46 | // Configure SQL Server (local) |
27 | 47 | Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services); |
28 | 48 | } |
29 | | -else{ |
| 49 | +else |
| 50 | +{ |
30 | 51 | // Configure SQL Server (prod) |
31 | 52 | Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services); |
32 | 53 | } |
33 | 54 |
|
| 55 | + |
34 | 56 | builder.Services.AddCookieSettings(); |
35 | 57 |
|
36 | 58 | builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) |
|
170 | 192 | app.UseHsts(); |
171 | 193 | } |
172 | 194 |
|
| 195 | +app.UseAzureAppConfiguration(); // Nuevo |
| 196 | + |
173 | 197 | app.UseHttpsRedirection(); |
174 | 198 | app.UseBlazorFrameworkFiles(); |
175 | 199 | app.UseStaticFiles(); |
|
0 commit comments