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 class OrderDiscountProcessor : IDiscountProcessor | |
{ | |
private readonly Discount _discount; | |
public OrderDiscountProcessor(Discount discount) | |
{ | |
_discount = discount; | |
} | |
public double ProcessDiscount(OrderViewModel order) |
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 async Task<IActionResult> Index() | |
{ | |
var vaultName = _configuration["AppSettings:KeyVaultName"]; | |
var secretName = _configuration["AppSettings:SecretName"]; | |
var vm = new HomeViewModel(); | |
try | |
{ | |
// Creating the Key Vault client |
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
// Creating the Key Vault client | |
var tokenProvider = new AzureServiceTokenProvider(); | |
var vaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(tokenProvider.KeyVaultTokenCallback)); |
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
[assembly: FunctionsStartup(typeof(Startup))] | |
namespace Function.DependencyInjection.Timer | |
{ | |
public class Startup : FunctionsStartup | |
{ | |
public override void Configure(IFunctionsHostBuilder builder) | |
{ | |
builder.Services.AddScoped<IHelloService, HelloService>(); | |
} | |
} |
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 Function.DependencyInjection.Timer | |
{ | |
public class TimeFunction | |
{ | |
private readonly IHelloService _helloService; | |
public TimeFunction(IHelloService helloService) | |
{ | |
_helloService = helloService; | |
} |
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
{ | |
"AppSettings": { | |
"KeyVaultName": "gabc-vault", | |
"HomePage": { | |
"Title": "Hello From Local App Settings", | |
"Description": "This description is taken from the appSettings.json." | |
}, | |
"ExternalService": { | |
"ClientId": "client-localhost", | |
"ApiKey": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" |
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(); |
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
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
{ | |
... | |
"FeatureManagement": { | |
"Promotion": false, | |
"Promotion.Discounts": false, | |
"Suggestion.User": false | |
} | |
} |