2016-12-07 85 views
1

現有VNET我有一個VNET成立於天青與多家每個都有自己的定義NSG入站和出站規則子網。部署Azure的資源管理器模板通過CLI

在這些子網中,我想用自動縮放規則(例如基於https://raw.githubusercontent.com/gbowerman/azure-myriad/master/vmss-ubuntu-scale/azuredeploy.json)部署具有特定擴展(可能從github/docker拉取一些回購)的VM縮放集。

在我的模板我怎麼定義的比例集合/ VM應分配給現有子網/ NSG等?

回答

1

嗯,這是相當簡單的,你只需要指定你引用的資源的ID。

比方說,您要使用現有網:

"parameters": { 
... 
    "existingVirtualNetworkName": { 
     "type": "string", 
     "metadata": { 
     "description": "Name of the existing VNET" 
     } 
    }, 
    "existingVirtualNetworkResourceGroup": { 
     "type": "string", 
     "metadata": { 
     "description": "Name of the existing VNET resource group" 
     } 
    }, 
    "subnetName": { 
     "type": "string", 
     "metadata": { 
     "description": "Name of the subnet in the virtual network you want to use" 
     } 
    }, 
... 
    }, 
    "variables": { 
... 
    "vnetID": "[resourceId(parameters('existingVirtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('existingVirtualNetworkName'))]", 
    "subnetRef": "[concat(variables('vnetID'),'/subnets/', parameters('subnetName'))]", 
... 
} 
    "resources": [ 
... 
    { 
    "apiVersion": "[variables('api-version')]", 
    "type": "Microsoft.Network/networkInterfaces", 
    "name": "[variables('nicName')]", 
    "location": "[resourceGroup().location]", 
    "dependsOn": [ 
     "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]" 
    ], 
    "tags": { 
     "displayName": "NetworkInterface" 
    }, 
    "properties": { 
     "ipConfigurations": [{ 
     "name": "ipconfig1", 
     "properties": { 
      "privateIPAllocationMethod": "Dynamic", 
      "publicIPAddress": { 
      "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" 
      }, 
      "subnet": { 
      "id": "[variables('subnetRef')]" 
      } 
     } 
     }] 
    } 
    }, 

你會使用網絡安全組相同的方法。

看看這裏更多:https://github.com/Azure/azure-quickstart-templates/blob/master/201-vm-specialized-vhd-existing-vnet/azuredeploy.json

+0

感謝您的快速答覆!如果我現有的VNET被稱爲stuartVNET,我將修改爲「現有虛擬網絡名稱」:{ 「type」:「string」, 「metadata」:{ 「description」:「現有VNET的名稱」 } stuartVNET「:{。」type:「string」...}或者是'existing'(existingVirtualNetworkName)某種類型的關鍵字,告訴Azure添加到現有資源中,並且它與描述值中的名稱匹配? –

+0

另外,當我以下parameters'供應值'existingVirtualNetworkName:設置參數,如existingVirtualNetworkName,existingVirtualNetworkResourceGroup當我部署使用CLI我得到提示爲這些提供值的模板,即''信息1 –

+0

沒有,那些都只是名字,如果你不不瞭解ARM模板是如何工作的 - 閱讀它們。2.是的,您需要爲所有參數提供值在部署時。 @StuartBrown – 4c74356b41

相關問題