This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Microsoft.FeatureManagement | |
{ | |
public enum RequirementType | |
{ | |
Any = 0, // The enabled state will be attained if any feature in the set is enabled. | |
All = 1 // The enabled state will be attained if all features in the set are enabled. | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.FeatureManagement.Mvc; | |
namespace MusicStore.Web.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
private readonly ILogger<HomeController> _logger; | |
private readonly IAlbumService _albumService; | |
private readonly IFeatureManager _featureManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model HomeViewModel | |
@{ | |
ViewData["Title"] = "Home Page"; | |
} | |
<div class="text-center"> | |
<feature name="@Features.PromotionDiscounts" negate="true"><h1 class="display-4">Enjoy the latest music from your favorite artist</h1></feature> | |
<feature name="@Features.PromotionDiscounts"><h1 class="display-4">Enjoy 25% off for selected albums from your favorite artist</h1></feature> | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@addTagHelper *, Microsoft.FeatureManagement.AspNetCore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MusicStore.Shared.FeatureManagement | |
{ | |
public static class Features | |
{ | |
public const string Promotions = "Promotion"; | |
public const string PromotionDiscounts = "Promotion.Discounts"; | |
public const string UserSuggestions = "Suggestion.User"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.FeatureManagement.Mvc; | |
namespace MusicStore.Web.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
... | |
[FeatureGate(Features.Promotions)] | |
public async Task<IActionResult> Promotions() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"FeatureManagement": { | |
"Promotion": false, | |
"Promotion.Discounts": false, | |
"Suggestion.User": false | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.FeatureManagement; | |
namespace MusicStore.Web | |
{ | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost | |
.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((context, config) => | |
{ | |
var settings = config.Build(); | |
// Connect to Azure App Configuration using the Connection String. | |
config.AddAzureAppConfiguration(settings["ConnectionStrings:AppConfiguration"]); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((ctx, config) => { | |
// Fetch app settings from Azure Key Vault if its in production mode. | |
if (ctx.HostingEnvironment.IsProduction()) | |
{ | |
var configRoot = config.Build(); | |
var tokenProvider = new AzureServiceTokenProvider(); |