How to pass variables between templates - ARM json

元气小坏坏 提交于 2020-01-16 01:55:29

问题


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]"
    },
}

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..


回答1:


In the main template, the variable should be:

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

Follow this walk through sharing state between templates



来源:https://stackoverflow.com/questions/35772904/how-to-pass-variables-between-templates-arm-json

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