Search code examples
azureazure-functionsfeaturetoggleazure-app-configuration

Usage of Azure App Configuration's Feature Flags in Azure Functions


I'm working on exploring the following 2 features of Azure App Configuration in Azure Function's Http Trigger

  1. Externalizing the App Settings
  2. Feature Flags

Below is how i'm getting the reference of the configuration

enter image description here

So, when I use _configuration["SomeAppSettingKey"], I'm able to retrieve the value. So, I'm able to achieve #1 feature mentioned above.

My Question is, How do we retrieve the Feature Flag information? I have tried the below ways.

enter image description here

I would appreciate if someone could help me in understanding how to retrieve it in Azure Functions (I'm using V3)? A Sample code or any reference to documentation would be helpful.

Thanks.

Update1: I can deserialize the json content as shown below. But, is this is the right approach?

enter image description here

Where FeatureManager is a class that I have defined as shown below.

enter image description here


Solution

  • all you need is to call UseFeatureFlags() function as part of AddAzureAppConfiguration to let the App Configuration provider know you want to use feature flags. An example can be found following the link below. It uses the FunctionsStartup and dependency injection (DI) of Azure Functions. An instance of a feature manager is put into the DI.

    https://github.com/Azure/AppConfiguration/blob/master/examples/DotNetCore/AzureFunction/FunctionApp/Startup.cs

    The link below shows how you can obtain the instance of IFeatureManagerSnapshot from DI and use it as part of your Azure Functions call.

    https://github.com/Azure/AppConfiguration/blob/master/examples/DotNetCore/AzureFunction/FunctionApp/ShowBetaFeature.cs