Author : MD TAREQ HASSAN | Updated : 2021/10/29

Get Tenant Id from Environment Variable

Create KeyVault

First, Create Resource Group

//
// Get TenantId
//
var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID", EnvironmentVariableTarget.Process);

//
// Create KeyVault
//
var vault = new AzureNative.KeyVault.Vault("DemoKeyVault", new AzureNative.KeyVault.VaultArgs
{
    ResourceGroupName = resourceGroup.Name,
    VaultName = "DemoKv",
    Location = "japaneast",
    Properties = new AzureNative.KeyVault.Inputs.VaultPropertiesArgs
    {
        Sku = new AzureNative.KeyVault.Inputs.SkuArgs
        {
            Name = AzureNative.KeyVault.SkuName.Standard,
            Family = AzureNative.KeyVault.SkuFamily.A
        },
        EnableRbacAuthorization = true,
        EnableSoftDelete = true,
        SoftDeleteRetentionInDays = 7,
        CreateMode = AzureNative.KeyVault.CreateMode.Default,
        EnabledForDeployment = true,
        EnabledForDiskEncryption = true,
        EnabledForTemplateDeployment = true,
        TenantId = tenantId
    }
});