Skip to content

Commit 3c1efca

Browse files
committed
fix: trim project prefix from keys
1 parent 09d8893 commit 3c1efca

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

WebApi/Program.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@
2020
const string PROJECT_ID = "ACM";
2121

2222
// Add services to the container.
23-
builder.Configuration.AddAzureAppConfiguration(options =>
24-
{
25-
var azureAppConfigConnectionString = builder.Configuration.GetConnectionString("AzureAppConfig");
26-
options.Connect(azureAppConfigConnectionString)
27-
.Select(keyFilter: $"{PROJECT_ID}_*")
28-
.Select(keyFilter: $"{PROJECT_ID}_*", labelFilter: builder.Environment.EnvironmentName)
29-
.ConfigureRefresh(x => x.SetCacheExpiration(TimeSpan.FromDays(1)));
30-
});
23+
builder.Configuration
24+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
25+
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true)
26+
.AddUserSecrets<Program>(optional: true, reloadOnChange: true)
27+
.AddAzureAppConfiguration(options =>
28+
{
29+
var azureAppConfigConnectionString = builder.Configuration.GetConnectionString("AzureAppConfig");
30+
options.Connect(azureAppConfigConnectionString)
31+
.Select(keyFilter: $"{PROJECT_ID}:*", LabelFilter.Null)
32+
.Select(keyFilter: $"{PROJECT_ID}:*", labelFilter: builder.Environment.EnvironmentName)
33+
.ConfigureRefresh(x => x
34+
.Register($"{PROJECT_ID}:AzureAppConfig:Sentinel", refreshAll: true)
35+
.SetCacheExpiration(TimeSpan.FromHours(1)))
36+
.TrimKeyPrefix($"{PROJECT_ID}:");
37+
});
3138

3239
ConfigureServices(builder.Services, builder.Configuration);
3340
ConfigureDataAccess(builder.Services, builder.Configuration);
@@ -102,12 +109,6 @@ static void ConfigureServices(IServiceCollection services, IConfiguration config
102109
opts.FallbackPolicy = policy;
103110
});
104111

105-
/*services.AddAuthentication(opts =>
106-
{
107-
opts.DefaultAuthenticateScheme = "";
108-
opts.DefaultChallengeScheme = "";
109-
});*/
110-
111112
services.Configure<RedditSettings>(configuration.GetSection("RedditSettings"));
112113

113114
services.AddMemoryCache();

WebApi/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
},
88
"AllowedHosts": "*",
99
"ConnectionStrings": {
10-
"DbConnection": ""
10+
"DbConnection": "",
11+
"AzureAppConfig": ""
1112
},
1213
"RedditSettings": {
1314
"AppId": "",

0 commit comments

Comments
 (0)