Last active
September 29, 2021 18:15
-
-
Save justinyoo/49b5a9a3d42dd21bbc68afe3ffd6a25f to your computer and use it in GitHub Desktop.
6 Ways Passing Secrets to ARM Templates
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
az group deployment create ` | |
-g "my-resource-group" ` | |
--template-file azuredeploy.json ` | |
--parameters `@azuredeploy.parameters.json ` | |
--parameters servicePrincipalTenantId=$tenantId |
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
# The tenand ID is randomly generated one. | |
$tenantId = ConvertTo-SecureString "da88225f-755d-4758-b6a6-3aaeba1e6264" ` | |
-AsPlainText ` | |
-Force | |
New-AzureRmResourceGroupDeployment ` | |
-ResourceGroupName "my-resource-group" ` | |
-TemplateFile azuredeploy.json ` | |
-TemplateParameterFile azuredeploy.parameters.json ` | |
-servicePrincipalTenantId $tenantId |
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
"parameters": { | |
"keyVaultSecretValue": { | |
"reference": { | |
"keyVault": { | |
"id": "/subscriptions/4c52543c-f468-4816-a4d8-7bb46a34e1b7/resourceGroups/rg-arm-kv/providers/Microsoft.KeyVault/vaults/kvarmkv" | |
}, | |
"secretName": "logicAppKey" | |
} | |
} | |
} |
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
parameters: | |
keyVaultSecretValue: | |
reference: | |
keyVault: | |
# The subscription ID is randomly generated one | |
id: "/subscriptions/4c52543c-f468-4816-a4d8-7bb46a34e1b7/resourceGroups/rg-arm-kv/providers/Microsoft.KeyVault/vaults/kvarmkv" | |
secretName: logicAppKey |
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
"parameters": { | |
"keyVaultSecretValue": { | |
"type": "securestring", | |
"metadata": { | |
"description": "Value of the secret from 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
parameters: | |
keyVaultSecretValue: | |
type: securestring | |
metadata: | |
description: Value of the secret from 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
"resources": [ | |
{ | |
"comments": "### RESOURCE - LOGIC APP ###", | |
"apiVersion": "[variables('linked').apiVersion]", | |
"type": "Microsoft.Resources/deployments", | |
"name": "[variables('deployments').logicApp]", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "https://raw.githubusercontent.com/devkimchi/Handling-Secrets-around-ARM-Templates/master/LogicApp.json" | |
}, | |
"parameters": { | |
"keyVaultSecretValue": { | |
"reference": { | |
"keyVault": { | |
"id": "[resourceId('Microsoft.KeyVault/vaults', variables('keyVault').name)]" | |
}, | |
"secretName": "[variables('keyVault').secrets.name]" | |
} | |
} | |
} | |
} | |
} | |
] |
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
resources: | |
- comments: "### RESOURCE - LOGIC APP ###" | |
apiVersion: "[variables('linked').apiVersion]" | |
type: Microsoft.Resources/deployments | |
name: "[variables('deployments').logicApp]" | |
properties: | |
mode: Incremental | |
templateLink: | |
uri: "https://raw.githubusercontent.com/devkimchi/Handling-Secrets-around-ARM-Templates/master/LogicApp.json" | |
parameters: | |
keyVaultSecretValue: | |
reference: | |
keyVault: | |
id: "[resourceId('Microsoft.KeyVault/vaults', variables('keyVault').name)]" | |
secretName: "[variables('keyVault').secrets.name]" |
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
"servicePrincipalTenantId": { | |
"type": "securestring", | |
"metadata": { | |
"description": "Tenant Id of the service principal." | |
} | |
} |
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
servicePrincipalTenantId: | |
type: securestring | |
metadata: | |
description: Tenant Id of the service principal. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment