几年后,Azure现在可以为虚拟机和云服务(Web和Worker角色)预留IP地址.但是,PowerShell目前只能访问(这在明天会有所改变).
前五个静态IP地址是免费的.要创建IP,您需要确保拥有Azure PowerShell command-line interface的最新版本,并且还将Azure帐户与Azure PowerShell相链接(在本文的范围之外但并不困难).
在PowerShell中创建新的IP:
$ReservedIP = New-AzureReservedIP -ReservedIPName "FirewallIP" -Label "WebAppFirewallIP" -Location "Japan West"
将其与VM关联:
New-AzureVMConfig -Name "WebAppVM" -InstanceSize Small -ImageName $images[60].ImageName | Add-AzureProvisioningConfig -Windows -AdminUsername cloudguy -Password Abc123 | New-AzureVM -ServiceName "WebApp" –ReservedIPName $ReservedIP -Location "Japan West"
要将新的IP插入Web或Worker角色(如果worker角色有外部端点),请将以下内容添加到ServiceConfiguration.Cloud.cscfg中:
<ServiceConfiguration> <NetworkConfiguration> <AddressAssignments> <ReservedIPs> <ReservedIP name="<reserved-ip-name>"/> </ReservedIPs> </AddressAssignments> </NetworkConfiguration> </ServiceConfiguration>
随时查看IP:
Get-AzureReservedIP -ReservedIPName "FirewallIP"
资料来源:Documentation