Skip to content

Instantly share code, notes, and snippets.

@bmoore-msft
Created February 22, 2016 21:40
Show Gist options
  • Save bmoore-msft/710284c0bd791a688e21 to your computer and use it in GitHub Desktop.
Save bmoore-msft/710284c0bd791a688e21 to your computer and use it in GitHub Desktop.
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
@laxmand17
Copy link

mykeyvoult

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