Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 5519ad0

Browse files
authored
Update feature configuration package and use different ids for feature flags (#2980)
1 parent f62fe0c commit 5519ad0

File tree

9 files changed

+73
-44
lines changed

9 files changed

+73
-44
lines changed

src/ApiService/ApiService/ApiService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0-preview3" />
1212
<PackageReference Include="Semver" Version="2.1.0" />
1313
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="5.1.0" />
14+
<PackageReference Include="Microsoft.Azure.AppConfiguration.Functions.Worker" Version="6.0.0" />
1515
<PackageReference Include="Microsoft.FeatureManagement" Version="2.5.1" />
1616
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
1717
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.0" />
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace Microsoft.OneFuzz.Service;
22

33
public static class FeatureFlagConstants {
4-
public const string EnableScribanOnly = "EnableScribanOnly";
4+
public const string RenderOnlyScribanTemplates = "RenderOnlyScribanTemplates";
55
public const string EnableNodeDecommissionStrategy = "EnableNodeDecommissionStrategy";
6-
public const string EnableValidateNotificationConfigSemantics = "EnableValidateNotificationConfigSemantics";
6+
public const string SemanticNotificationConfigValidation = "SemanticNotificationConfigValidation";
77
}

src/ApiService/ApiService/Program.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,7 @@ public static async Async.Task Main() {
6565
});
6666
}
6767
})
68-
.ConfigureFunctionsWorkerDefaults(builder => {
69-
builder.UseMiddleware<LoggingMiddleware>();
70-
builder.AddApplicationInsights(options => {
71-
options.ConnectionString = $"InstrumentationKey={configuration.ApplicationInsightsInstrumentationKey}";
72-
});
73-
})
7468
.ConfigureServices((context, services) => {
75-
services.AddAzureAppConfiguration();
76-
_ = services.AddFeatureManagement();
7769
services.Configure<JsonSerializerOptions>(options => {
7870
options = EntityConverter.GetJsonSerializerOptions();
7971
});
@@ -139,7 +131,17 @@ public static async Async.Task Main() {
139131
.AddSingleton<IStorage, Storage>()
140132
.AddSingleton<ILogSinks, LogSinks>()
141133
.AddHttpClient()
142-
.AddMemoryCache();
134+
.AddMemoryCache()
135+
.AddAzureAppConfiguration();
136+
137+
_ = services.AddFeatureManagement();
138+
})
139+
.ConfigureFunctionsWorkerDefaults(builder => {
140+
builder.UseAzureAppConfiguration();
141+
builder.UseMiddleware<LoggingMiddleware>();
142+
builder.AddApplicationInsights(options => {
143+
options.ConnectionString = $"InstrumentationKey={configuration.ApplicationInsightsInstrumentationKey}";
144+
});
143145
})
144146
.Build();
145147

src/ApiService/ApiService/onefuzzlib/NotificationOperations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ public async Async.Task<OneFuzzResult<Notification>> Create(Container container,
9191
return OneFuzzResult<Notification>.Error(ErrorCode.INVALID_REQUEST, "invalid container");
9292
}
9393

94-
if (await _context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.EnableScribanOnly) &&
94+
if (await _context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.RenderOnlyScribanTemplates) &&
9595
!await JinjaTemplateAdapter.IsValidScribanNotificationTemplate(_context, _logTracer, config)) {
9696
return OneFuzzResult<Notification>.Error(ErrorCode.INVALID_REQUEST, "The notification config is not a valid scriban template");
9797
}
9898

99-
if (await _context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.EnableValidateNotificationConfigSemantics)) {
99+
if (await _context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.SemanticNotificationConfigValidation)) {
100100
var validConfig = await config.Validate();
101101
if (!validConfig.IsOk) {
102102
return OneFuzzResult<Notification>.Error(validConfig.ErrorV);

src/ApiService/ApiService/onefuzzlib/notifications/NotificationsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static async Async.Task<Renderer> ConstructRenderer(
7676
inputUrl = new Uri(context.Containers.AuthDownloadUrl(report.InputBlob.Container, report.InputBlob.Name));
7777
}
7878

79-
var scribanOnlyFeatureFlag = await context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.EnableScribanOnly);
79+
var scribanOnlyFeatureFlag = await context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.RenderOnlyScribanTemplates);
8080
log.Info($"ScribanOnlyFeatureFlag: {scribanOnlyFeatureFlag}");
8181

8282
var scribanOnly = scribanOnlyOverride ?? scribanOnlyFeatureFlag;

src/ApiService/ApiService/packages.lock.json

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@
157157
"resolved": "0.12.2",
158158
"contentHash": "JgMAGj8ekeAzKkagubXqf1UqgfHq89GyA1UQYWbkAe441uRr2Rh2rktkx5Z0LPwmD/aOqu9cxjekD2GZjP8rbw=="
159159
},
160+
"Microsoft.Azure.AppConfiguration.Functions.Worker": {
161+
"type": "Direct",
162+
"requested": "[6.0.0, )",
163+
"resolved": "6.0.0",
164+
"contentHash": "cwj73rhjH27VOg5pGB7mlTkX6do96u733T8m8int62RuxcQRKQVTuzh91hpQYFsf9IFAgS/RAwdO7fTAPJ7vOA==",
165+
"dependencies": {
166+
"Microsoft.Azure.Functions.Worker": "1.6.0",
167+
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "6.0.0"
168+
}
169+
},
160170
"Microsoft.Azure.Functions.Extensions": {
161171
"type": "Direct",
162172
"requested": "[1.1.0, )",
@@ -272,21 +282,6 @@
272282
"System.Net.Http": "4.3.0"
273283
}
274284
},
275-
"Microsoft.Extensions.Configuration.AzureAppConfiguration": {
276-
"type": "Direct",
277-
"requested": "[5.1.0, )",
278-
"resolved": "5.1.0",
279-
"contentHash": "FoAfgvT/rjL/+c7BP7q0LrJIdc4Hu6SH56BTIUbwCwVjHoUw4dpgGtLQULi5GmMjdbdAxyLQSnbwpOEWuBy+RA==",
280-
"dependencies": {
281-
"Azure.Data.AppConfiguration": "1.2.0",
282-
"Azure.Messaging.EventGrid": "4.7.0",
283-
"Azure.Security.KeyVault.Secrets": "4.0.1",
284-
"Microsoft.Extensions.Configuration": "3.1.18",
285-
"Microsoft.Extensions.DependencyInjection.Abstractions": "3.1.18",
286-
"Microsoft.Extensions.Logging": "3.1.18",
287-
"System.Text.Json": "4.6.0"
288-
}
289-
},
290285
"Microsoft.FeatureManagement": {
291286
"type": "Direct",
292287
"requested": "[2.5.1, )",
@@ -724,6 +719,20 @@
724719
"Microsoft.Extensions.Primitives": "7.0.0"
725720
}
726721
},
722+
"Microsoft.Extensions.Configuration.AzureAppConfiguration": {
723+
"type": "Transitive",
724+
"resolved": "6.0.0",
725+
"contentHash": "oRCr8qqBp/37CXttfgbEWnPznHy0/ZCkgNVFFQ5cnXGvG8TBWicnAK032opyrbGIH3n2jYSg/PvIw7aLoOTy3Q==",
726+
"dependencies": {
727+
"Azure.Data.AppConfiguration": "1.2.0",
728+
"Azure.Messaging.EventGrid": "4.7.0",
729+
"Azure.Security.KeyVault.Secrets": "4.3.0",
730+
"Microsoft.Extensions.Configuration": "3.1.18",
731+
"Microsoft.Extensions.DependencyInjection.Abstractions": "3.1.18",
732+
"Microsoft.Extensions.Logging": "3.1.18",
733+
"System.Text.Json": "4.7.2"
734+
}
735+
},
727736
"Microsoft.Extensions.Configuration.Binder": {
728737
"type": "Transitive",
729738
"resolved": "5.0.0",

src/ApiService/IntegrationTests/packages.lock.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@
374374
"resolved": "7.0.4",
375375
"contentHash": "LrTtzEkC28PBGDpohPtMOf26a8Sg5yvQyEtlG7z2YB93qloK2u8sqG6BDzj0rBiz/mpyVlkc8Nj36IJCvqWtPg=="
376376
},
377+
"Microsoft.Azure.AppConfiguration.Functions.Worker": {
378+
"type": "Transitive",
379+
"resolved": "6.0.0",
380+
"contentHash": "cwj73rhjH27VOg5pGB7mlTkX6do96u733T8m8int62RuxcQRKQVTuzh91hpQYFsf9IFAgS/RAwdO7fTAPJ7vOA==",
381+
"dependencies": {
382+
"Microsoft.Azure.Functions.Worker": "1.6.0",
383+
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "6.0.0"
384+
}
385+
},
377386
"Microsoft.Azure.Functions.Extensions": {
378387
"type": "Transitive",
379388
"resolved": "1.1.0",
@@ -645,16 +654,16 @@
645654
},
646655
"Microsoft.Extensions.Configuration.AzureAppConfiguration": {
647656
"type": "Transitive",
648-
"resolved": "5.1.0",
649-
"contentHash": "FoAfgvT/rjL/+c7BP7q0LrJIdc4Hu6SH56BTIUbwCwVjHoUw4dpgGtLQULi5GmMjdbdAxyLQSnbwpOEWuBy+RA==",
657+
"resolved": "6.0.0",
658+
"contentHash": "oRCr8qqBp/37CXttfgbEWnPznHy0/ZCkgNVFFQ5cnXGvG8TBWicnAK032opyrbGIH3n2jYSg/PvIw7aLoOTy3Q==",
650659
"dependencies": {
651660
"Azure.Data.AppConfiguration": "1.2.0",
652661
"Azure.Messaging.EventGrid": "4.7.0",
653-
"Azure.Security.KeyVault.Secrets": "4.0.1",
662+
"Azure.Security.KeyVault.Secrets": "4.3.0",
654663
"Microsoft.Extensions.Configuration": "3.1.18",
655664
"Microsoft.Extensions.DependencyInjection.Abstractions": "3.1.18",
656665
"Microsoft.Extensions.Logging": "3.1.18",
657-
"System.Text.Json": "4.6.0"
666+
"System.Text.Json": "4.7.2"
658667
}
659668
},
660669
"Microsoft.Extensions.Configuration.Binder": {
@@ -2487,6 +2496,7 @@
24872496
"Azure.Storage.Blobs": "[12.13.0, )",
24882497
"Azure.Storage.Queues": "[12.11.0, )",
24892498
"Faithlife.Utility": "[0.12.2, )",
2499+
"Microsoft.Azure.AppConfiguration.Functions.Worker": "[6.0.0, )",
24902500
"Microsoft.Azure.Functions.Extensions": "[1.1.0, )",
24912501
"Microsoft.Azure.Functions.Worker": "[1.10.0, )",
24922502
"Microsoft.Azure.Functions.Worker.ApplicationInsights": "[1.0.0-preview3, )",
@@ -2498,7 +2508,6 @@
24982508
"Microsoft.Azure.Functions.Worker.Sdk": "[1.7.0, )",
24992509
"Microsoft.Azure.Management.Monitor": "[0.28.0-preview, )",
25002510
"Microsoft.Azure.Management.OperationalInsights": "[0.24.0-preview, )",
2501-
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "[5.1.0, )",
25022511
"Microsoft.FeatureManagement": "[2.5.1, )",
25032512
"Microsoft.Graph": "[4.37.0, )",
25042513
"Microsoft.Identity.Client": "[4.52.0, )",

src/ApiService/Tests/packages.lock.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,15 @@
423423
"resolved": "7.0.4",
424424
"contentHash": "LrTtzEkC28PBGDpohPtMOf26a8Sg5yvQyEtlG7z2YB93qloK2u8sqG6BDzj0rBiz/mpyVlkc8Nj36IJCvqWtPg=="
425425
},
426+
"Microsoft.Azure.AppConfiguration.Functions.Worker": {
427+
"type": "Transitive",
428+
"resolved": "6.0.0",
429+
"contentHash": "cwj73rhjH27VOg5pGB7mlTkX6do96u733T8m8int62RuxcQRKQVTuzh91hpQYFsf9IFAgS/RAwdO7fTAPJ7vOA==",
430+
"dependencies": {
431+
"Microsoft.Azure.Functions.Worker": "1.6.0",
432+
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "6.0.0"
433+
}
434+
},
426435
"Microsoft.Azure.Functions.Extensions": {
427436
"type": "Transitive",
428437
"resolved": "1.1.0",
@@ -694,16 +703,16 @@
694703
},
695704
"Microsoft.Extensions.Configuration.AzureAppConfiguration": {
696705
"type": "Transitive",
697-
"resolved": "5.1.0",
698-
"contentHash": "FoAfgvT/rjL/+c7BP7q0LrJIdc4Hu6SH56BTIUbwCwVjHoUw4dpgGtLQULi5GmMjdbdAxyLQSnbwpOEWuBy+RA==",
706+
"resolved": "6.0.0",
707+
"contentHash": "oRCr8qqBp/37CXttfgbEWnPznHy0/ZCkgNVFFQ5cnXGvG8TBWicnAK032opyrbGIH3n2jYSg/PvIw7aLoOTy3Q==",
699708
"dependencies": {
700709
"Azure.Data.AppConfiguration": "1.2.0",
701710
"Azure.Messaging.EventGrid": "4.7.0",
702-
"Azure.Security.KeyVault.Secrets": "4.0.1",
711+
"Azure.Security.KeyVault.Secrets": "4.3.0",
703712
"Microsoft.Extensions.Configuration": "3.1.18",
704713
"Microsoft.Extensions.DependencyInjection.Abstractions": "3.1.18",
705714
"Microsoft.Extensions.Logging": "3.1.18",
706-
"System.Text.Json": "4.6.0"
715+
"System.Text.Json": "4.7.2"
707716
}
708717
},
709718
"Microsoft.Extensions.Configuration.Binder": {
@@ -2614,6 +2623,7 @@
26142623
"Azure.Storage.Blobs": "[12.13.0, )",
26152624
"Azure.Storage.Queues": "[12.11.0, )",
26162625
"Faithlife.Utility": "[0.12.2, )",
2626+
"Microsoft.Azure.AppConfiguration.Functions.Worker": "[6.0.0, )",
26172627
"Microsoft.Azure.Functions.Extensions": "[1.1.0, )",
26182628
"Microsoft.Azure.Functions.Worker": "[1.10.0, )",
26192629
"Microsoft.Azure.Functions.Worker.ApplicationInsights": "[1.0.0-preview3, )",
@@ -2625,7 +2635,6 @@
26252635
"Microsoft.Azure.Functions.Worker.Sdk": "[1.7.0, )",
26262636
"Microsoft.Azure.Management.Monitor": "[0.28.0-preview, )",
26272637
"Microsoft.Azure.Management.OperationalInsights": "[0.24.0-preview, )",
2628-
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "[5.1.0, )",
26292638
"Microsoft.FeatureManagement": "[2.5.1, )",
26302639
"Microsoft.Graph": "[4.37.0, )",
26312640
"Microsoft.Identity.Client": "[4.52.0, )",

src/deployment/bicep-templates/feature-flags.bicep

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ resource featureFlags 'Microsoft.AppConfiguration/configurationStores@2022-05-01
1313

1414
resource configStoreFeatureflag 'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' = {
1515
parent: featureFlags
16-
name: '.appconfig.featureflag~2FEnableScribanOnly'
16+
name: '.appconfig.featureflag~2FRenderOnlyScribanTemplates'
1717
properties: {
1818
value: string({
19-
id: 'EnableScribanOnly'
19+
id: 'RenderOnlyScribanTemplates'
2020
description: 'Render notification templates with scriban only'
2121
enabled: false
2222
})
@@ -26,10 +26,10 @@ resource configStoreFeatureflag 'Microsoft.AppConfiguration/configurationStores/
2626

2727
resource validateNotificationConfigSemantics 'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' = {
2828
parent: featureFlags
29-
name: '.appconfig.featureflag~2FEnableValidateNotificationConfigSemantics'
29+
name: '.appconfig.featureflag~2FSemanticNotificationConfigValidation'
3030
properties: {
3131
value: string({
32-
id: 'EnableScribanOnly'
32+
id: 'SemanticNotificationConfigValidation'
3333
description: 'Check notification configs for valid PATs and fields'
3434
enabled: true
3535
})

0 commit comments

Comments
 (0)