Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Azure Resource Manager template using a User-Defined Function to create the Storage Connection String
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"functions": [
{
"namespace": "storage",
"members": {
"connectionString": {
"parameters": [
{
"name": "accountName",
"type": "string"
},
{
"name": "accountKey",
"type": "string"
}
],
"output": {
"type": "string",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('accountName'), ';AccountKey=', parameters('accountKey'), ';EndpointSuffix=core.windows.net')]"
}
}
}
}
],
"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": "[storage.connectionString('loremipsumstore', listKeys(resourceId('Microsoft.Storage/storageAccounts', 'loremipsumstore'), '2019-06-01').keys[0].value)]"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', 'LoremVault')]",
"[resourceId('Microsoft.Storage/storageAccounts', 'loremipsumstore')]"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.