Skip to content

Instantly share code, notes, and snippets.

@bachoang
Created January 3, 2019 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bachoang/f712488ddd72ab9eed7c6b0e2115ce61 to your computer and use it in GitHub Desktop.
Save bachoang/f712488ddd72ab9eed7c6b0e2115ce61 to your computer and use it in GitHub Desktop.
Powershell to create Azure Key Vault
Connect-AzureRmAccount
$RGName = "BlogKVRG"
$location = "East US"
$KVName = "BlogKV123"
# Create a new Resource Group
New-AzureRmResourceGroup -Name $RGName -Location $location
# Create a new Azure Key Vault
New-AzureRmKeyVault -Name $KVName -ResourceGroupName $RGName -Location $location
# setting a new secret in the key vault
$secretvalue = ConvertTo-SecureString 'Pa$$w0rd' -AsPlainText -Force
$secret = Set-AzureKeyVaultSecret -VaultName $KVName -Name 'SQLPassword' -SecretValue $secretvalue
# get back the secret value
(get-azurekeyvaultsecret -vaultName $KVName -name "SQLPassword").SecretValueText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment