如何将 Azure 保留 IP(经典)迁移到 Azure Public IP (ARM)?

How can I migrate an Azure Reserved IP (classic) to an Azure Public IP (ARM)?

将 Azure 中的服务从经典模型迁移到 Azure 资源管理器 (ARM) 时,您的经典模型中可能有一些保留的 IP 地址。保留 IP 的 ARM 对应物是 public IP。创建新的 public IP 将产生另一个 IP 地址,并可能导致已将您的 IP 地址列入白名单的客户端出现问题。

尽管最好使用基于 FQDN 的白名单。然而,有时这是不可能的,IP 白名单是次佳的选择。如何在不获取新 IP 地址的情况下从保留 IP 地址迁移到 public IP 地址?

本主题的实际功劳归功于 Vatsana Kongtakane log entry。我已经对项目进行了调整,因为我认为大多数人都已经拥有了预留IP。我把它放在 Whosebug 上的原因是为了防止信息丢失。

第 1 步 – 登录并准备您的 ARM 环境

# Login to your ARM account
Add-AzureRmAccount

# Get a list of available subscriptions
Get-AzureRMSubscription

# Select your subscription
Select-AzureRmSubscription -SubscriptionName <SubscriptionName>

# Register migration provider, this can take a couple minuites
Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate

# View the current RegistrationState status, do not proceed to step 2 until the status says Registered
Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate

第 2 步 – 登录您的经典帐户

# Login to your ASM account
Add-AzureAccount

# Get a list of available subscriptions
Get-AzureSubscription

# Select your subscription
Select-AzureSubscription –SubscriptionName <SubscriptionName>

第 3 步 – 迁移您保留的 IP 地址

# Show the list of all reserved IP addresses
Get-AzureReservedIP

# De-associate the reserved IP address from your cloud service
# (only necessary if the IP is still assigned to a service)
Remove-AzureReservedIPAssociation -ReservedIPName <ReservedIPName> -ServiceName <ServiceName>

# Check for issues during migration
Move-AzureReservedIP -ReservedIPName <ReservedIPName> -Validate

# Prepare the ReservedIP for migration
Move-AzureReservedIP -ReservedIPName <ReservedIPName> -Prepare

# Commit to migrating the ReservedIP (take a pretty long time)
Move-AzureReservedIP -ReservedIPName <ReservedIPName> -Commit

第 4 步 – 验证和清理

此时如果您登录 portal.azure.com,您应该会在 Public IP 地址下看到具有正确 IP 地址的资源。正在转移到新的资源组中,您可以将其移动到您喜欢的资源组中。

我无法让旧的 ASM PowerShell 命令在 Azure 门户的云 Shell 中工作。下面介绍如何使用 Azure CLI 将经典保留 IP 迁移到 Public IP。

azure account set <subscriptionNameOrId>
azure provider register Microsoft.ClassicInfrastructureMigrate
azure provider show Microsoft.ClassicInfrastructureMigrate
azure config mode asm
azure network reserved-ip list
azure network reserved-ip disassociate <name> <service-name> <deployment-name>
azure network reserved-ip list
azure network reserved-ip validate-migration <name>
azure network reserved-ip prepare-migration <name>
azure network reserved-ip commit-migration <name>

安装模块 Azure

Install-Module Azure -AllowClobber #{关闭 powershell 并重新打开}

导入模块 Azure

{保留经典IP}

https://docs.microsoft.com/en-us/previous-versions/azure/virtual-network/virtual-networks-reserved-public-ip#reserve-the-ip-address-of-an-existing-cloud-service

New-AzureReservedIP –ReservedIPName MyReservedIP –Location "美国中部" -ServiceName busa

###服务名称 = busa ## ==> DNS 名称:- Busa.cloudapp.net