如何在JSON的另一部分创建的部分中检索特定的资源名称?

huangapple go评论67阅读模式
英文:

How to retrieve certain resourcename in a section created in another section of JSON?

问题

"CopyUniqueNameToArmParameters": [
"vmName"
]

英文:

How does this work in JSON ARM templates?

"CopyUniqueNameToArmParameters": [
  "vmName"
]

I am working with ARM template where in one section where ARM template to create virtual machine is getting called. and in that section above snippet is being used. Now in another section I need to use his vmName but not sure how it is deciding the VMName and how to retrieve it for next section.

答案1

得分: 0

CopyUniqueNameToArmParameters 是一个自定义函数,它将资源的唯一名称复制到一个 ARM 参数中。

在您的情况下,它将虚拟机的名称复制到名为 VMName 的 ARM 参数中。在另一个部分,您可以通过引用该参数名来获取 VMName 的值。

要检索 VMName,请使用以下语法:

resources:[
{ 
     "name": "[parameters('VMName')]"
 }
 ]

注意: VMName 作为参数提供给需要它的资源。

传递给 CopyUniqueNameToArmParameters 的值是将存储唯一名称的 ARM 模板参数的名称。在给定情况下,唯一名称会复制到 VMName 参数中。

有关更多相关信息,请参阅MSDoc

英文:

CopyUniqueNameToArmParameters is a custom function that copies a resource's unique name to an ARM parameter.

In your case, it copies the virtual machine's name to an ARM parameter called VMName. In another section, you can get the value of VMName by referencing the parameter name.

To retrieve the VMName, use the below syntax:

resources:[
{ 
     "name": "[parameters('VMName')]"
 }
 ]

Note: The VMName is supplied as a parameter to the resource that requires it.

The value passed to CopyUniqueNameToArmParameters is the name of the ARM template parameter that will store the unique name. The unique name is copied to the VMName parameter in the given scenario.

Refer MSDoc for more relevant information.

huangapple
  • 本文由 发表于 2023年7月3日 23:14:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76606056.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定