问题
I have searched and read the documentation of Resource Management Template, but i couldn't find any information over Environment variables. I tried to define 2 environment variables in a variable object, but it didn't work.
variables": {
"mailPass": "TYUl5491",
"SlackToken": "hrtu-12546233785-55454578422-56454412348-87845155121ht5621552521er55547123"
}
Is there any way to define environment variables in an Azure Resource Management Template and then use it for the web app or api app?
回答1:
Yes, for a WebApp you can do that, here's the snippet of a full WebApp resource, replace values and names with something you need:
{
"apiVersion": "2015-08-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('location')]",
"properties": {
"serverFarmId": "[parameters('hostingPlanName')]",
"siteConfig": {
"appSettings": [
{
"name": "storageKey", # REPLACE ME
"value": "[listKeys(variables('storageid'),'2015-06-15').key1]" # REPLACE ME
},
{
"name": "storageAccount", # REPLACE ME
"value": "[parameters('storageAccountName')]" # REPLACE ME
}
]
}
}
}
来源:https://stackoverflow.com/questions/43124084/how-to-use-an-environment-variable-in-an-azure-resource-management-template