AZ-400 Question 173
Single answerYou administer an Azure App Configuration resource that stores multiple feature flags, including one named 'ShoppingCartPreview.' You plan to enable this feature only in your staging environment while keeping it disabled in production, using the same codebase. You have already integrated your .NET Core application with Azure App Configuration Feature Manager. Which approach should you use to ensure environment-specific behavior for 'ShoppingCartPreview' without duplicating code logic?
- A
Create two distinct feature flags (�ShoppingCartPreview_Staging� and �ShoppingCartPreview_Prod�) and enable or disable them individually within each environment� App Configuration instance.
- B
Use the same feature flag name with different labels for staging and production. Configure your application to request the flag with the matching label for the current environment.
- C
Configure the feature manager to read an environment variable and override the feature flag status at runtime for each environment, bypassing labels entirely.
- D
Duplicate the feature flag entries in Azure App Configuration and manually toggle the correct entry each time you deploy your application to a specific environment.
Show answer and explanation
Correct answer: B
Explanation
Using labels in Azure App Configuration is a best practice to manage environment-specific variations of the same feature flag. By referencing the label in your application� startup code, you ensure that the correct feature status is pulled for each environment. For detailed guidance, see Microsoft� official documentation on using labels with Azure App Configuration at https://learn.microsoft.com/azure/azure-app-configuration/howto-labels.
- A. Incorrect.
Option 1: While this approach could work, it introduces extra complexity because you need to manage multiple differently named flags. Although functional, it� not the recommended practice for environment-specific settings. Using labels is more straightforward and aligns better with Azure App Configuration best practices.
- B. Correct.
Option 2 (Correct): This is the recommended way to handle environment-specific feature flags using Azure App Configuration. You create a single flag name, 'ShoppingCartPreview,' but assign distinct labels (e.g., 'Staging' and 'Production'). In your .NET Core code, you configure the client libraries to request the feature flag with the label corresponding to the deployment environment. This avoids duplication and ensures consistent naming across environments.
- C. Incorrect.
Option 3: Depending on environment variables alone to override feature statuses can become cumbersome and lacks the clarity provided by labeled flags. You also lose the straightforward environment-based segmentation that labels offer in Azure App Configuration.
- D. Incorrect.
Option 4: Duplicating feature flag entries is generally not a best practice because it creates more overhead, increases the risk of inconsistent settings, and complicates deployment pipelines. It� better to use labels to isolate environment-specific configurations.