Prior to starting on Azure App Configuration Service, I was writing about Git Branching Strategies. In that series, we have already discussed that the
Trunk Based Development is basically preferred over other strategies, because it provides some additional benefits when it comes to reducing the operational complexities while developing and deploying the applications.
Trunk Based Development strategy, the feature releases are managed via feature flags. If any new feature is being developed, it is kept behind the feature toggle until it is ready for release. So, although the feature is getting deployed, user cannot see/experience those features until the feature flag is turned on.
Azure App Configuration Service provides a feature called as feature management. The feature management is a modern software development practice that decouples feature release from code deployment and enables quick changes to feature availability on demand. Feature management is done via feature flags (also called as feature toggles or feature switches).
In this article, we are going to have a look at how feature management can be done via App Configuration Service.
There are three basic terms that we should know.
- Feature Flags or feature switch or feature toggle is basically a Boolean setting, which can be set to on (i.e. true) or off (i.e. false).
- Feature Management, is basically an application package that handles the life cycle of all the feature flags in an application. It may also provide additional functionalities like caching and updating the states of feature flags.
- Filter: A filter is a rule for evaluating the state of a feature flag. Potential filters include user groups, device or browser types, geographic locations, and time windows. These filters can be helpful to implement conditional feature flags.
How to use Feature Flags ?
Generally, there should be a repository of feature flags which is responsible for reading the flags from the store. Then based on whether the flag is on or off, we can selectively enable some parts of the application.
The code snippet given below shows am example usage. If there are alternative code paths, an if….else construct can be used. If we just want to hide the feature, then only if statement can be used.
Create Feature Flags
In rest of the article, we are going to have a look at how the feature flags can be created. For that, we will need an instance of Azure App Configuration Service. You can refer this article to create one using Azure Portal. Alternatively, you can run the bicep script from this article to create one for you.
Once the instance is created, navigate to the resource. Open an Azure App Configuration store and then open Operations menu -> select Feature Manager -> Create. This should open a new panel.
Next, it will show a new screen, as shown in the snapshot given below. Let’s discuss what inputs we can provide.
First input, is the checkbox, Enable feature flag, which is to specify the value of the feature flag.
Then, we can specify Feature flag name, which is mandatory input. This is the identifier for the feature flag. It should be unique. Then, there is an input with name Key, which has a path prefix and then the value of Feature flag name is populated in the text box by default. We can change the key and prefix the value with any logical prefix that we want.
Optionally, we can also add Label and the Description for the feature flag. There is another input, Use feature filter which is a checkbox to sepcify if we want to add any rules for the feature flag. For the sake of this article, we can keep this to its default value.
Now, click on Apply to create the feature flag. Once the feature flag is created, it will be shown in the list as shown in the snapshot given below. We can also edit the flag if needed, by clicking on the three dots on the right hand side and selecting Edit option from the context menu.
Feature flags created with the Feature Manager are stored and retrieved as regular key-values. They’re kept under a special namespace prefix
In this article, we have seen how to add feature flag in the App Configuration Service. In the coming article, we will have a look at how use this flag in the core.
I hope you find this information helpful. Let me know your thoughts.