如何在模板之间传递变量-ARM json [英] How to pass variables between templates - ARM json

查看:158
本文介绍了如何在模板之间传递变量-ARM json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,将链接模板中的变量(普通字符串)传递回我的主模板.

I'm looking for a way to pass a variable (normal string) from a linked template back up to my main template.

我想使用类似:(在链接模板中)

I want to use something like: (in linked template)

 "outputs": {
  "installStringNodes": {
    "type": "string",
    "value": "[variables('installString').value]"
  }
}    

然后我想将此变量调用到我的主模板中.但是我似乎无法破解.

And then i want to call this variable into my main template. But i can't seem to crack how.

"variables":{
   "installStringFromNodeResources": {
      "value": "[??('node-resources')??.outputs.installStringNodes.value]"
    },
}

存在一个使用reference()的资源管理器模板中的共享状态"文档,但显然不能在变量中使用,因为它在尝试部署时给了我一个错误. 在我看来,应该对此有一个简单的解决方案,但我还没有看到它..

There's a 'sharing state in resource manager templates' doc with the usage of reference() but apparently that can't be used in variables as it gives me an error while trying to deploy. Seems to me there should be an easy solution for this but i haven't been able to see it yet..

推荐答案

在主模板中,变量应为:

In the main template, the variable should be:

"installStringFromNodeResources": { "value": "[reference('node-resources').outputs.installStringNodes.value]" }

"installStringFromNodeResources": { "value": "[reference('node-resources').outputs.installStringNodes.value]" }

按照以下步骤进行操作:模板

Follow this walk through sharing state between templates

这篇关于如何在模板之间传递变量-ARM json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆