簡體   English   中英

Azure ARM 模板中 concat 函數和資源 id 函數的區別

[英]Difference between concat function and resource id function in Azure ARM Template

誰能告訴我這兩者之間有什么區別,以及應該在 Azure ARM JSON 模板的資源部分中使用哪一個

"dependsOn": [
      [concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"
"dependsOn": [
      [resourceid('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"

resourceId 只是一種生成 resourceId 的便捷方式,而不是“假”的方式,因為如果您嘗試將 concat 示例與任何需要 resourceId 的 function\\resource 屬性一起使用,則您所展示的示例僅適用於dependsOn 屬性將失敗。

基本上,dependsOn 在解析輸入時允許使用幾個快捷方式,因此您可以執行以下操作:

dependsOn: [
    "resourceName"
]

如果該名稱是唯一的 - 那很好。 但它不是您可能認為的真正的 resourceId。

連接: https : //docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array#concat
資源IDhttps : //docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#resourceid

“連接”功能:

  • 將多個數組合並為一個數組
    或者
  • 將多個字符串組合成單個字符串

有關更多詳細信息,請參閱此鏈接

而“resourceId”函數:

  • 它給出了被調用的資源的唯一標識符。 有關更多詳細信息,請參閱此鏈接

現在回答“應該在 Azure ARM JSON 模板的資源部分中使用哪個”的問題。 以下,我在我的 ARM 模板中使用了它,它對我有用:

"availabilitySet": { "id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySetName'))]" }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM