如何在Azure资源管理模板中使用环境变量 [英] How to use an Environment variable in an Azure Resource Management Template
本文介绍了如何在Azure资源管理模板中使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经搜索并阅读了资源管理模板的文档,但是找不到有关环境变量的任何信息.我试图在一个变量对象中定义2个环境变量,但这没有用.
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"
}
是否可以在Azure资源管理模板中定义环境变量,然后将其用于Web应用程序或api应用程序?
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?
推荐答案
是的,对于WebApp,您可以做到这一点,这是完整的WebApp资源的片段,将值和名称替换为所需的内容:
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
}
]
}
}
}
这篇关于如何在Azure资源管理模板中使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文