繁体   English   中英

如何在变量中使用 Azure Arm 模板 Output?

[英]How to use an Azure Arm Template Output in a variable?

I'm trying to solve a problem I'm having with an Azure ARM template, whereby I need to capture the output of a queried resource in my ARM template, then in that same template, feed that output into a variable / inject that output到另一个依赖它的资源上的脚本中。

一个例子 -

   "outputs":{
      "downloadLocation": {
        "type": "string",
        "value": "[reference(resourceId('randomResource', variables('ResourceName'))).downloadLocation]"
      }
   }

variables: {
    "downloadLocation": "[outputs('downloadLocation')]"
}

然后在依赖于查询的 output 的源的资源之一中引用此变量。

downloadLocation 无论如何都无法格式化,它包含多个签名和不可预测的字符串。

仅供参考 - 下面的代码通过产生错误“模板 function '输出'无效”来停止使用 arm 模板。

我没有锁定将其存储为 output,我只需要能够在另一个资源中使用该值 - 但是它已经实现了!

我知道的唯一其他路线可行,但我还不想探索,是 output 可以存储在某个文件中,然后后续脚本将其拾取并将其注入第二个 ARM 模板。

如果有使用它的方法,请告诉我,这将对我有很大帮助!

谢谢

我找到了解决方案。 在资源字段中可以调用引用 function。 所以我不得不使用参考 function ,如上所示,但它不能存储在变量或参数中,而是需要直接在需要它的资源中调用。 在这种情况下是 osProfile - customData 字段。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM