ARM模板对象 [英] ARM Template Object

查看:63
本文介绍了ARM模板对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 


我试图找出是否可以将来自parameters.json的值直接传递给template.json中的对象。


似乎必须将参数添加到template.json中,模板对象才能使用这些参数,这基本上意味着将参数加倍。

" vNetSettings":{
" type":" object",
" defaultValue":{
" name":" parameters('vNetName' )",
" location":" [parameters('location')]",
" addressPrefixes":[
{
" name": "vNetaddressSpace",
" addressPrefix":" [parameters('addressSpace')]"
}
]

 所以我需要传递vnetname的值而不必添加vnetname作为参数



希望有意义



解决方案

您好TommyWebApp,


感谢您与我们联系!


有两种方法可以将参数传递给template.json。一个是内联的,一个是通过参数文件。


您正在讨论在部署ARM模板时内联传递参数。 


https://docs.microsoft.com/ en-us / azure / azure-resource-manager / resource-group-template-deploy#pass-parameter-values



内联参数



要传递内联参数,请使用  New-AzResourceGroupDeployment  命令提供参数的名称。例如,要将字符串和数组传递给模板,请使用:

 


arrayParam =" value1"," ;值2"
New-AzResourceGroupDeployment -ResourceGroupName testgroup`
-TemplateFile c:\ MyTemplates \ demotemplate.json`
-exampleString" inline string" `
-exampleArray


arrayParam


希望这会有所帮助!


Hi, 

Im trying to find if its possible to pass values from the parameters.json directly into a object with in the template.json.

It seems that parameters have to be added to the template.json for the template object to consume these, which basically means doubling up on the parameters.

     "vNetSettings": {
            "type": "object",
            "defaultValue": {
                "name": "parameters('vNetName')",
                "location": "[parameters('location')]",
                "addressPrefixes": [
                  {
                    "name": "vNetaddressSpace",
                    "addressPrefix": "[parameters('addressSpace')]"
                  }
                ]

 So i need to pass the value of vnetname with out having to add the vnetname as a parameter

Hope that makes sense

解决方案

Hi TommyWebApp,

Thank you for reaching out!

There are two ways of passing the parameters to template.json. One is inline and one is through parameter file.

You are talking about passing the parameters inline while deploying an ARM template. 

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy#pass-parameter-values

Inline parameters

To pass inline parameters, provide the names of the parameter with the New-AzResourceGroupDeployment command. For example, to pass a string and array to a template, use:


arrayParam = "value1", "value2" New-AzResourceGroupDeployment -ResourceGroupName testgroup ` -TemplateFile c:\MyTemplates\demotemplate.json ` -exampleString "inline string" ` -exampleArray


arrayParam

Hope this helps!


这篇关于ARM模板对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆