Skip to content

Instantly share code, notes, and snippets.

@eNeRGy164
Last active March 19, 2021 06:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save eNeRGy164/19c9dea85994526052e666f4d0e734c7 to your computer and use it in GitHub Desktop.
Save eNeRGy164/19c9dea85994526052e666f4d0e734c7 to your computer and use it in GitHub Desktop.
Deployment Template sample adding Secrets to a Azure Key Vault
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.KeyVault/vaults",
"name": "LoremVault",
"apiVersion": "2015-06-01",
"location": "[resourceGroup().location]",
"properties": {
"sku": {
"family": "A",
"name": "Standard"
},
"tenantId": "[subscription().tenantId]",
"accessPolicies": [
{
"tenantId": "[subscription().tenantId]",
"objectId": "CHANGETO-YOUR-USER-GUID-000000000000",
"permissions": {
"keys": [ "All" ],
"secrets": [ "All" ]
}
}
]
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"kind": "Storage",
"name": "loremipsumstore",
"apiVersion": "2016-01-01",
"sku": {
"name": "Standard_LRS"
},
"location": "[resourceGroup().location]"
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "LoremVault/SomeSecret",
"apiVersion": "2015-06-01",
"properties": {
"contentType": "text/plain",
"value": "ThisIpsemIsSecret"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', 'LoremVault')]"
]
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "LoremVault/SomeCertificate",
"apiVersion": "2015-06-01",
"properties": {
"contentType": "application/x-pkcs12",
"value": "MIIV0QIBAzCC...LoremIpsum...RIJcq3QACAggA"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', 'LoremVault')]"
]
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "LoremVault/ConnectionString",
"apiVersion": "2015-06-01",
"properties": {
"contentType": "text/plain",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=loremipsumstore;AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', 'loremipsumstore'), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value, ';')]"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', 'LoremVault')]",
"[resourceId('Microsoft.Storage/storageAccounts', 'loremipsumstore')]"
]
}
]
}
@ivica77
Copy link

ivica77 commented Jun 11, 2018

Why you adding plain text as a secret and a certificate as a secret too? Do we need both?

@MrCNeale
Copy link

How do you then reference the secret for a later deployment?

@khalsa13
Copy link

Why you adding plain text as a secret and a certificate as a secret too? Do we need both?

These are two different secrets.

@khalsa13
Copy link

khalsa13 commented Mar 19, 2021

How do you then reference the secret for a later deployment?

Use azure function to fetch these secrets (using secret name )from key vault and use them wherever required.

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