How to create Azure Feature Flag for the App Configuration through c# code?

666 Views Asked by At

I am using .net core 3 to create configuration setting in App configuration. I was able to create a key-value in the configuration explorer using the following code snippet and some additional configuration in the link below

var client = new ConfigurationClient(_configuration.GetConnectionString("AppConnectionString"));
var settingToCreate = new ConfigurationSetting(model.Key, model.Value);
client.SetConfigurationSetting(settingToCreate);

https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/appconfiguration/Azure.Data.AppConfiguration/README.md#create-a-configuration-setting

I am currently working on creating a feature flag in feature manager pane of App Configuration using the same approach but providing the contenttype for featureflag as below.

var client = new ConfigurationClient(_configuration.GetConnectionString("AppConnectionString"));
var settingToCreate = new ConfigurationSetting(model.Key, model.Value);
settingToCreate.ContentType = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8";
client.SetConfigurationSetting(settingToCreate);

The issue is it creates a feature flag but without a name, showing an error message as below configuration explorer

feature manager

Please suggest any possible solutions. Thanks in advance!

3

There are 3 best solutions below

0
On

Please see this sample for managing feature flags with the .NET SDK for App Configuration.

0
On

I find you can add .appconfig.featureflag/new by using Azure App Configuration client library for .NET.

But you can't create .appconfig.featureflag/new in configuration explorer on portal. You can check the image like below. You also can try in your side.

enter image description here

So I think this is a problem with the library and there are no restrictions.

0
On

I was able to implement the entire end-to-end scenario for feature flag management and usage. You can find the post here