azure-quickstart-templates / 101-subnet-add-vnet-existing /が元ネタでして、このテンプレートは、すでに作成済みの仮想ネットワークに対して追加ができるものです。
元ネタをカスタマイズしたものと元ネタの違いは、diff(Bash on Ubuntu on Windowsですよ!)をとっても
norio@SURFACEPRO:/mnt/c/Users/Norio/OneDrive/Documents/armTemplate$ diff armTemplate.json armTemplate-Add\ a\ subnet\ to\ an\ existing\ VNET.json
12a13
> "defaultValue": "GatewaySubnet",
32c33
< "name": "existingVNETName/newSubnetName",
---
> "name": "[concat(parameters('existingVNETName'),'/',parameters('newSubnetName'))]",
だけです。新規に作成するサブネット名をデフォルトで定義するようにしたこと、既存の仮想ネットワークと指定したサブネット名を用いるようにしたことが違いです。
※こちらを先にカスタマイズして、VPNゲートウェイを追加したのが、githubのAzure Resource Manager テンプレートをカスタマイズしてみた - 仮想ネットワークにGatewayサブネットとVPN Gatewayを追加になります。
ということで、JSONのソースファイルを貼っておきます。 ※Azure Resource Managerでデプロイ確認済みです。
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"existingVNETName": {
"type": "string",
"metadata": {
"description": "Name of the VNET to add a subnet to"
}
},
"newSubnetName": {
"type": "string",
"defaultValue": "GatewaySubnet",
"metadata": {
"description": "Name of the subnet to add"
}
},
"newSubnetAddressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
"metadata": {
"description": "Address space of the subnet to add"
}
}
},
"variables": {
"apiVersion": "2015-06-15"
},
"resources": [
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Network/virtualNetworks/subnets",
"name": "[concat(parameters('existingVNETName'),'/',parameters('newSubnetName'))]",
"location": "[resourceGroup().location]",
"properties": {
"addressPrefix": "[parameters('newSubnetAddressPrefix')]"
}
}
],
"outputs": {}
}
0 件のコメント:
コメントを投稿