我正在使用以下API创建VM:
https://management.azure.com/subscriptions/{{subscription-id}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.Compute/virtualMachines/{{vmName}}?api-version=2017-12-01
身体:
{
"location": "westus",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_D1_v2"
},
"storageProfile": {
"imageReference": {
"sku": "2016-Datacenter",
"publisher": "MicrosoftWindowsServer",
"version": "latest",
"offer": "WindowsServer"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "myVMosdisk",
"createOption": "FromImage"
}
},
"osProfile": {
"adminUsername": "{your-username}",
"computerName": "myVM",
"adminPassword": "{your-password}"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
"properties": {
"primary": true
}
}
]
}
}
}
然后,我必须运行命令以打开虚拟机端口:
az vm open-port --resource-group "my-rg" --name "my-vm" --port 3389
我想知道是否可以在发送请求时将其包含在json中,所以我不需要执行操作即可通过命令行工具打开端口。
答案 0 :(得分:2)
肯定是。检查this example ARM模板,该模板可创建VM以及具有打开的入站端口22的网络安全组。
只需将其调整为Windows VM。 Here is a sample template用于Windows VM(无NSG)。