Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Create an Azure KeyVault Enabled for Template Deployment (sh and ps)
#!/bin/bash -e
# A script to create an Azure KeyVault enabled for template deployment
#Change the values below before running the script
vaultName="myvault" #Globally Unique Name of the KeyVault
vaultLocation="East US" #Location of the KeyVault
resourceGroupName="vaults" #Name of the resource group for the vault
resourceGroupLocation="East US" #Location of the resource group if it needs to be created
#Login and Select the default subscription if needed
#azure login
#azure account set "subscription name"
azure config mode arm
azure group create "$resourceGroupName" "$resourceGroupLocation"
azure keyvault create --vault-name "$vaultName" --resource-group "$resourceGroupName" --location "$vaultLocation"
azure keyvault set-policy "$vaultName" --enabled-for-template-deployment true
#Requires -Module AzureRM.Profile
#Requires -Module AzureRM.KeyVault
#Login and Select the default subscription if needed
#Login-AzureRmAccount
#Select-AzureRmSubscription -SubscriptionName 'subscription name'
#Change the values below before running the script
$VaultName = 'myvault' #Globally Unique Name of the KeyVault
$VaultLocation = 'East US' #Location of the KeyVault
$ResourceGroupName = 'vaults' #Name of the resource group for the vault
$ResourceGroupLocation = 'East US' #Location of the resource group if it needs to be created
New-AzureRmResourceGroup -Name $ResourceGroupName -Location $ResourceGroupLocation -Force
New-AzureRmKeyVault -VaultName $VaultName -ResourceGroupName $ResourceGroupName -Location $VaultLocation -EnabledForTemplateDeployment

mykeyvoult

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment