Azure ARM 模板中的多个 IP 地址变量
Multiple IP address variable in Azure ARM Template
如果我使用 ARM 模板在 Azure 中创建 IP 组并希望添加多个 IP 地址作为参数而不是将它们放入资源主体中,这可能吗?
模板如下
{
"type": "Microsoft.Network/ipGroups",
"apiVersion": "2021-05-01",
"name": "string",
"location": "string",
"tags": {
"tagName1": "tagValue1",
"tagName2": "tagValue2"
},
"properties": {
"ipAddresses": [ "10.10.10.10",
"10.10.10.11" ]
}
}
如果我创建如下参数
"ipgipaddress": {
"type": "string
"Value":
"10.10.10.10",
"10.10.10.11"
}
并将代码更新为
{
"type": "Microsoft.Network/ipGroups",
"apiVersion": "2021-05-01",
"name": "string",
"location": "string",
"tags": {
"tagName1": "tagValue1",
"tagName2": "tagValue2"
},
"properties": {
"ipAddresses": "[parameters('ipgroupsettings')]"
}
}
want to add Multiple IP Addresses as a Parameter rather than putting
them in the body of the resource is this possible?
是的,您可以添加多个 IP 地址作为参数。根据 documentation,属性 ipAddresses
是字符串数组类型。
为了重现这一点,在我们的 ARM 模板中,我们已将那些 ipaddresses
初始化为数组类型的参数,并使用 "[paramerter(ipaddresses)]"
.
进一步传递这些值
我们已经测试过了,它工作正常。
这是 ARM 模板 :
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ipaddress":{
"type": "array",
"defaultValue": ["10.0.1.0/27","10.0.2.0/27"]
}
},
"functions": [],
"variables": {},
"resources": [{
"type": "Microsoft.Network/ipGroups",
"apiVersion": "2020-11-01",
"name": "testipgroups",
"location":"[resourceGroup().location]",
"properties":{
"ipAddresses": "[parameters('ipaddress')]"
}
}
],
"outputs": {}
}
这里是示例输出以供参考:
如果我使用 ARM 模板在 Azure 中创建 IP 组并希望添加多个 IP 地址作为参数而不是将它们放入资源主体中,这可能吗?
模板如下
{
"type": "Microsoft.Network/ipGroups",
"apiVersion": "2021-05-01",
"name": "string",
"location": "string",
"tags": {
"tagName1": "tagValue1",
"tagName2": "tagValue2"
},
"properties": {
"ipAddresses": [ "10.10.10.10",
"10.10.10.11" ]
}
}
如果我创建如下参数
"ipgipaddress": {
"type": "string
"Value":
"10.10.10.10",
"10.10.10.11"
}
并将代码更新为
{
"type": "Microsoft.Network/ipGroups",
"apiVersion": "2021-05-01",
"name": "string",
"location": "string",
"tags": {
"tagName1": "tagValue1",
"tagName2": "tagValue2"
},
"properties": {
"ipAddresses": "[parameters('ipgroupsettings')]"
}
}
want to add Multiple IP Addresses as a Parameter rather than putting them in the body of the resource is this possible?
是的,您可以添加多个 IP 地址作为参数。根据 documentation,属性 ipAddresses
是字符串数组类型。
为了重现这一点,在我们的 ARM 模板中,我们已将那些 ipaddresses
初始化为数组类型的参数,并使用 "[paramerter(ipaddresses)]"
.
我们已经测试过了,它工作正常。
这是 ARM 模板 :
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ipaddress":{
"type": "array",
"defaultValue": ["10.0.1.0/27","10.0.2.0/27"]
}
},
"functions": [],
"variables": {},
"resources": [{
"type": "Microsoft.Network/ipGroups",
"apiVersion": "2020-11-01",
"name": "testipgroups",
"location":"[resourceGroup().location]",
"properties":{
"ipAddresses": "[parameters('ipaddress')]"
}
}
],
"outputs": {}
}
这里是示例输出以供参考: