簡體   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