我正在使用静态(保留)IP 地址创建 VM
$adminUser = "*****"
$password = "*****"
$reservedIP = "myIP"
# VM Creation Details
$vmName = "*****"
$vmSize = "Small"
$serviceName = "*****"
$location = "West Europe"
$imageFamily = "Windows Server 2012 R2 Datacenter"
$imageName = Get-AzureVMImage |
where { $_.ImageFamily -eq $imageFamily } |
sort PublishedDate -Descending |
select -ExpandProperty ImageName -First 1
# create reserved IP
New-AzureReservedIP – ReservedIPName $reservedIP –Label $reservedIP –Location $location
# Create a virtual machine configuration object
$vm = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -ImageName $imageName |`
Add-AzureProvisioningConfig -Windows `
-AdminUsername $adminUser `
-Password $password
New-AzureVM -ServiceName $serviceName -Location $location `
-VMs $vm `
-ReservedIPName $reservedIP # Specify the reserved IP address for the external VIP
这里一切正常。
但我有网络“我的网络”,还有子网,例如“FrontEndSubnet”。如何将 vm 放入此子网?我正在尝试这样
$vm2 = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -ImageName $imageName |`
Add-AzureProvisioningConfig -Windows `
-AdminUsername $adminUser `
-Password $password | `
Set-AzureSubnet "FrontEndSubnet"
New-AzureVM -ServiceName $serviceName -Location $location `
-VMs $vm2 `
-ReservedIPName $reservedIP # Specify the reserved IP address for the external VIP
但得到了
New-AzureVM:BadRequest:虚拟网络 ID 不能为空或为空。
我试过用单引号
-Password $password | Set-AzureSubnet 'FrontEndSubnet'
但同样的结果。可能吗?