How to use an Environment variable in an Azure Resource Management Template

淺唱寂寞╮ 提交于 2019-12-07 21:57:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!