【发布时间】:2020-11-13 07:58:52
【问题描述】:
寻找一些关于如何输出我的应用服务实例名称的反馈。我与 CopyIndex 合作过,但我不明白我该怎么做。
首先是我的参数。请注意,我使用数组作为参数位置。
"parameters": {
"location": {
"type": "array",
"metadata": {
"description": "array of region"
},
"allowedValues": [
"centralus",
"eastus"
]
}
然后我实例化我的 AppServices 并迭代我的不同位置
{ // App Services
"type": "Microsoft.Web/sites",
"name": "[concat(variables('appServiceName'), parameters('location')[copyIndex()])]",
"apiVersion": "2018-11-01",
"copy": {
"name": "Copy website",
"count": "[length(parameters('location'))]"
},
"location": "[parameters('location')[copyIndex()]]",
"tags": {
"cost": "[parameters('Stage')]"
}
....
效果很好,现在我想输出应用服务实例名称:
"outputs": {
"websitesname": {
"type": "array",
"copy": {
"count": "[length(parameters('location'))]",
"input":{
"id": "here i struggle :("
}
}
}
}
我真的不知道如何获取实例名称? 首先,我尝试返回 variable 的值,但失败了。其次,我尝试返回 reference 的值,但又失败了。
有什么想法吗?
更新 1 我应用了 Stringfellow 提供的建议,我得到的和你的截图一样。
我可以使用 $deploymentResult.Outputs.keyVaultName.Value 检索 KeyVault 名称
但是对于 appServicename 我没有运气。我尝试了 $deploymentResult.Outputs.websitesname.Value 然后尝试分离该值,但它失败了。我也尝试转换为 json。我相信它存在一种聪明的方式。根据我的示例,我如何检索值 AppService-Prod-centralus 和 AppService-Prod-eastus ?
【问题讨论】:
标签: azure azure-resource-manager arm-template