2015-12-08 83 views

回答

0

您可以使用Visual Studio資源集團項目,這將幫助你生成JSON模板虛擬機,你可以提交使用PowerShell或API直接模板,

{ 
    "apiVersion": "2015-06-15", 
    "type": "Microsoft.Compute/virtualMachines", 
    "name": "[variables('vmName')]", 
    "location": "[resourceGroup().location]", 
    "tags": { 
    "displayName": "VirtualMachine" 
    }, 
    "dependsOn": [ 
    "[concat('Microsoft.Storage/storageAccounts/', variables('vhdStorageName'))]", 
    "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" 
    ], 
    "properties": { 
    "hardwareProfile": { 
     "vmSize": "[variables('vmSize')]" 
    }, 
    "osProfile": { 
     "computerName": "[variables('vmName')]", 
     "adminUsername": "[parameters('adminUsername')]", 
     "adminPassword": "[parameters('adminPassword')]" 
    }, 
    "storageProfile": { 
     "imageReference": { 
     "publisher": "[variables('imagePublisher')]", 
     "offer": "[variables('imageOffer')]", 
     "sku": "[parameters('windowsOSVersion')]", 
     "version": "latest" 
     }, 
     "osDisk": { 
     "name": "osdisk", 
     "vhd": { 
      "uri": "[concat('http://', variables('vhdStorageName'), '.blob.core.windows.net/', variables('vhdStorageContainerName'), '/', variables('OSDiskName'), '.vhd')]" 
     }, 
     "caching": "ReadWrite", 
     "createOption": "FromImage" 
     } 
    }, 
    "networkProfile": { 
     "networkInterfaces": [ 
     { 
      "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" 
     } 
     ] 
    }, 
    "diagnosticsProfile": { 
     "bootDiagnostics": { 
     "enabled": true, 
     "storageUri": "[concat('http://', variables('diagnosticsStorageName'), '.blob.core.windows.net')]" 
     } 
    } 
    }, 

爲Power Shell腳本

# Create or update the resource group using the specified template file and template parameters file 

新AzureRmResourceGroup -Name $ ResourceGroupName -Location $ ResourceGroupLocation -Verbose -Force -ErrorAction停止

新AzureRmResourceGroupDeployment -Name((GET-ChildItem $ TemplateFile).BaseName + ' - ' +((獲取最新).ToUniversalTime())。的ToString( '月日-HHMM')) -ResourceGroupName $ResourceGroupName -TemplateFile $ TemplateFile -TemplateParameterFile $TemplateParametersFile @OptionalParameters` -Force -Verbose

+0

非常感謝!非常有用 – zhitongLiu

+0

如果它解決了您的問題,請將其標記爲答案 – ZeeMoussa

0

您應該使用Azure的資源管理模板,使您可以使用您想要創建的模板 說明環境聲明的形式在這裏 https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/ 你會在GitHub上(尋找蔚藍髮現許多樣品-quickstart-templates)

如果您仍然希望使用python SDK,則必須進行相應的REST API調用。關於這樣一個很好的文章是在這裏: http://blogs.msdn.com/b/scicoria/archive/2015/02/12/azure-resource-manager-creating-an-iaas-vm-within-a-vnet.aspx

希望這有助於 問候 斯特凡

+0

THX,這是非常有益的。 – zhitongLiu

+0

我想知道他們是否會更新他們的python SDK來使它做好工作 – zhitongLiu

相關問題