Last active
March 19, 2021 06:34
-
-
Save eNeRGy164/19c9dea85994526052e666f4d0e734c7 to your computer and use it in GitHub Desktop.
Deployment Template sample adding Secrets to a Azure Key Vault
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$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')]" | |
] | |
} | |
] | |
} |
How do you then reference the secret for a later deployment?
Why you adding plain text as a secret and a certificate as a secret too? Do we need both?
These are two different secrets.
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
Why you adding plain text as a secret and a certificate as a secret too? Do we need both?