我正在构建Web应用程序并使用ARM模板将其部署到Azure中。我正在创建和部署它们没有任何问题。我试图在输出会话中访问contentVersion。但是,我收到了一条消息
无法评估模板输出
我通过以下方式尝试了它:
"outputs": {
"Contentoutput": {
"type": "string",
"value": "[reference('contentVersion')]" //First case
"value": "[reference('contentVersion').value]" //Second case
"value": "['contentVersion']" //Third case
"value": "[contains('contentVersion','contentVersion')]" //Fourth case
}
}
如何在输出会话中访问contentVersion?
输出内容版本的更好方法是使用部署功能(请参阅documentation)。
您的解决方案解决方案将转换为:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [],
"outputs": {
"contentVersion": {
"type": "string",
"value": "[deployment().properties.template.contentVersion]"
}
}
}
我也找不到在输出中获取它的方法。根据azure官方文档,我们可以知道contentVersion可以提供你提供的价值。
contentVersion:模板的版本(例如1.0.0.0)。您可以为此元素提供任何值。使用模板部署资源时,可以使用此值来确保使用正确的模板。
所以我的解决方法是你可以将它定义为参数然后你可以从输出中获取它。以下是演示代码。你也可以给Azure团队提供your idea
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"contentVersion": {
"type": "string",
"defaultValue": "1.0.0.0",
"metadata": {
"description": "contentVersion"
}
}
},
"variables": {
},
"resources": [
],
"outputs": {
"contentVersion": {
"type": "string",
"value": "[parameters('contentVersion')]"
}
}
}