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
services.AddScoped<IDiscountProcessor, OrderDiscountProcessor>(); | |
services.AddScoped<IDiscount, SeasonalDiscount>(); | |
services.AddScoped<IDiscount, LargeOrderDiscount>(); | |
services.AddScoped<IDiscount, ThreeOrModeDiscount>(); |
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
services.TryAddEnumerable(ServiceDescriptor.Scoped<IThreeService, ThreeService>()); | |
// or | |
services.TryAddEnumerable(new[] { | |
ServiceDescriptor.Scoped<IThreeService, ThreeService>(), | |
ServiceDescriptor.Scoped<IThreeService, AwesomeThreeService>(), | |
ServiceDescriptor.Scoped<IThreeService, SuperAwesomeThreeService>() | |
}); |
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
services.Replace(ServiceDescriptor.Scoped<IFourService, FourService>()); |
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
var fourService = ServiceDescriptor.Scoped<IFourService, FourService>(); | |
services.Add(fourService); |
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
var threeService = ServiceDescriptor.Scoped(typeof(IThreeService), typeof(ThreeService)); | |
services.Add(threeService); |
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
var twoService = ServiceDescriptor.Describe(typeof(ITwoService), typeof(TwoService), ServiceLifetime.Scoped); | |
services.Add(twoService); |
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
var oneService = new ServiceDescriptor(typeof(IOneService), typeof(OneService), ServiceLifetime.Scoped); | |
services.Add(oneService); |
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
# Login to Azure | |
az login --use-device-code | |
# Check the registration Status of the Resource Provider | |
az provider list --query "[?namespace == 'Microsoft.Compute']" --output table | |
# Register the Microsoft.Compute Resource Provider | |
az provider register --namespace "Microsoft.Compute" |
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
# Login to Azure Subscription | |
Login-AzureRmAccount | |
# Check the registration Status of the Resource Provider | |
Get-AzureRmResourceProvider -ListAvailable | Where-Object { $_.ProviderNamespace -eq "Microsoft.Compute" } | |
# Register the Microsoft.Compute Resource Provider | |
Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.Compute" |
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
# Login to Azure | |
az login --use-device-code | |
# Get Regerence to Resource Group | |
$rgId = az group show --name "az-policy-rg" --query "id" --output tsv | |
# Get Reference to the Azure Policy Definition | |
$policyName = az policy definition list --query "[?displayName == 'Audit use of classic virtual machines'].name" --output tsv | |
# Assign the policy |