Created
May 19, 2020 11:55
-
-
Save eNeRGy164/4daa1ac3d7a383074f19fcb6202d14ef to your computer and use it in GitHub Desktop.
Azure Resource Manager template using a User-Defined Function to create the Storage Connection String
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", | |
"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