创建具有保留IP的VM

时间:2014-10-17 20:32:59

标签: azure

我尝试使用这样的保留IP地址创建一个VM:

New-AzureQuickVM -ImageName a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201409.01-en.us-127GB.vhd -ServiceName VmPIPBis3 -Windows -AdminUsername amethyste -Location“West Europe”-Password SuperMotDePasse12 -ReservedIPName 104.45.13.146

但我得到的只是这个错误信息:

New-AzureQuickVM:BadRequest:保留的IP 104.45.13.146不存在。

唯一创建的是服务云

有人知道发生了什么吗?

感谢

1 个答案:

答案 0 :(得分:2)

您需要首先在Azure订阅中保留IP,然后在调用New-AzureQuickVM时将ReservedIPName(不是地址)传递给 ReservedIPName 参数。下面是一个脚本,如果对于给定的名称不存在,则创建新的保留IP,然后使用保留的IP创建新VM。

$location = "West US"
$appVMName = "AppVM01"
$appVMServiceName = [Guid]::NewGuid().ToString();
$imageName = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201409.01-en.us-127GB.vhd"
$adminUser = "AdminUser"
$adminPswd = "AdminPassw0rd"
$reservedIPName = $appVMName + "-resrvdIP"

# Get the reserved IP if it exists or create a new one.
$reservedIP = Get-AzureReservedIP -ReservedIPName $reservedIPName -ErrorAction SilentlyContinue
if ($reservedIP -eq $null)
{
    Write-Host "Reserving IP in '$location' as '$reservedIPName'."
    New-AzureReservedIP -ReservedIPName $reservedIPName -Location $location
    $reservedIP = Get-AzureReservedIP -ReservedIPName $reservedIPName -ErrorAction Stop
}

# Create a new VM using the reserved IP
New-AzureQuickVM -Name $appVMName -ServiceName $appVMServiceName -Windows -ImageName $imageName `
  -AdminUsername $adminUser -Password $adminPswd -Location $location -ReservedIPName $reservedIP.ReservedIPName

Write-Host "VM Created using the following reserved IP Address:... " + $reservedIP.Address