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



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

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

本主题的实际学分是此日志条目中的 Vatsana Kongtakane。我已经改编了这些项目,因为我认为大多数人已经有一个保留的IP。我把它放在StackOverflow上的原因是为了防止信息丢失。

步骤 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,则应在"公共 IP 地址"下看到具有正确 IP 地址的资源。它正在传输到新的资源组,但你可以将其移动到所需的资源组。

我无法让旧的ASM PowerShell命令在Azure Portal的Cloud Shell中工作。下面介绍如何使用 Azure CLI 将经典保留 IP 迁移到公共 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>

install-module Azure

Install-Module Azure -AllowClobber#{关闭电源外壳并重新打开}

Import-Module Azure

{保留经典IP}

https://learn.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 ">Central US" -ServiceNamebusa

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

最新更新