Larger features may take a long time to develop, but you still want to deploy production updates during development. Or maybe you want the users to be able to preview upcoming features? Either way, feature flags can resolve the issue.
In this presentation we take a look at using feature flags in an ASP.NET Core application running in Azure App Service. We use the Microsoft.FeatureManagement library to support both development-time feature flags and user-specific preview feature flags. The Azure App Configuration service's feature flag support is also explored.
2. Speaker intro
• Joonas Westlin
• Developer / Architect @ Zure
• Worked with Azure for 8 years
@JoonasWestlin
joonasw.net
3. Contents
• What are feature flags?
• What scenarios are they used for?
• Microsoft.FeatureManagement library
• Azure App Configuration
Please ask questions whenever!
Links at the end for the slides and samples
5. What are feature flags?
• Aka “feature toggles”
• Allow you to modify system behaviour without modifying the code
• “Toggle points” decide where the code flow should go based on the flag
Calculate bonus
accrued for
purchase
Algorithm
version 1
Algorithm
version 2
Toggle point
8. What kind of scenarios
are feature flags used in?
9. What kind of scenarios are feature
flags used in?
1. Enable a new feature only in Dev/Test
• Aka “release toggles”
• Enable deployments while feature is in progress
2. Canary release of feature
• Test feature with small portion, release to rest if good
3. A/B testing
• Compare versions through metrics
4. Opt-in public previews
• Users can preview upcoming changes and give feedback
5. Premium features
• Enabled for users who have paid a higher fee
10. Microsoft.FeatureManagement
• Library for handling feature flags in .NET
applications
• Can use for simple on/off feature flags + more
complex scenarios
• Filters specify conditions when a feature should be
enabled, custom logic
• Integrates with ASP.NET Core
• Integrates with Azure App Configuration
16. Azure App Configuration
• Central management of settings and feature flags
• Can be a shared store for multiple services
• Change settings without application restarts
• Azure AD/access key authentication
• Store secrets in Key Vault and refer to them in settings
• Free and Standard tier
19. Release toggles
• Long development time, want to keep it hidden from users until it’s
ready
• Still want to be able to deploy often
• Release toggles hide/disable features until they are ready to be released
Deploy version,
enabled in dev/test,
disabled in prod
Deploy new version,
enabled in all
environments
20. Canary testing
• Deploy feature first to subset of users
• Ensure everything runs OK
• Deploy feature to more users
• If problems arise, only subset of users affected
Deploy version
Enable feature
for random 20%
Check telemetry
for some time
Enable feature
for all users
21. Opt-in public previews
• Give users the choice to try new features
• Users tend to allow issues/worse performance etc. in this case
• Get feedback
Deploy version
Users can opt in
to feature
Deploy new
version, enabled
for all users
23. Thoughts/Conclusions
• Use feature flags to change system behaviour per environment/per user
etc.
• Feature flags come with a cost, try to minimize their amount
• Try to minimize the amount of toggle points for a feature as well
• Remove flags once they become unnecessary
• Except for “premium features” etc.
• Usage of Microsoft.FeatureManagement library is recommended
• Azure App Configuration is very useful as a configuration/feature flag
store
Demo the NewsSummary flag locally, start with it disabled and switch it to enabled while the app is running.
Refresh the page and see that the news block is now shown.
Show how the Feature Management library has been added and talk briefly about the configuration file format.
Pretty much same demo as the first one, but this time in the Azure app.
Audience can participate by “creating” a user.
Start with the flag disabled, toggle it on in App Configuration, refresh page until feature is enabled.
Show the code for enabling App Configuration in the app.
Show the RBAC role assigned to the App Service.