将活动 DNS 名称迁移到 Azure 应用服务Migrate an active DNS name to Azure App Service

本文介绍如何在不停机的情况下,将活动 DNS 名称迁移到 Azure 应用服务This article shows you how to migrate an active DNS name to Azure App Service without any downtime.

将实时站点及其 DNS 域名迁移到应用服务时,该 DNS 名称已在提供实时流量。When you migrate a live site and its DNS domain name to App Service, that DNS name is already serving live traffic. 可以在迁移期间提前将活动 DNS 名称绑定到应用服务应用,从而避免 DNS 解析中的停机时间。You can avoid downtime in DNS resolution during the migration by binding the active DNS name to your App Service app preemptively.

如果你不担心 DNS 解析中的停机时间,请参阅将现有的自定义 DNS 名称映射到 Azure 应用服务If you're not worried about downtime in DNS resolution, see Map an existing custom DNS name to Azure App Service.

先决条件Prerequisites

若要完成本操作说明:To complete this how-to:

提前绑定域名Bind the domain name preemptively

提前绑定自定义域时,对 DNS 记录进行任何更改之前,需要完成以下两项操作:When you bind a custom domain preemptively, you accomplish both of the following before making any changes to your DNS records:

  • 验证域所有权Verify domain ownership
  • 为应用启用域名Enable the domain name for your app

最终将自定义 DNS 名称从旧站点迁移到应用服务应用时,DNS 解析中将不会有停机时间。When you finally migrate your custom DNS name from the old site to the App Service app, there will be no downtime in DNS resolution.

通过域提供商访问 DNS 记录Access DNS records with domain provider

Note

可以使用 Azure DNS 为 Azure Web 应用配置自定义 DNS 名称。You can use Azure DNS to configure a custom DNS name for your Azure Web Apps. 有关详细信息,请参阅使用 Azure DNS 为 Azure 服务提供自定义域设置For more information, see Use Azure DNS to provide custom domain settings for an Azure service.

登录到域提供商的网站。Sign in to the website of your domain provider.

查找管理 DNS 记录的页面。Find the page for managing DNS records. 每个域提供商都有自己的 DNS 记录界面,因此请查阅提供商的文档。Every domain provider has its own DNS records interface, so consult the provider's documentation. 查找站点中标记为“域名”、“DNS”或“名称服务器管理”的区域。 Look for areas of the site labeled Domain Name, DNS, or Name Server Management.

通常通过查看帐户信息,然后查找如“我的域”之类的链接,便可以找到 DNS 记录页面 。Often, you can find the DNS records page by viewing your account information, and then looking for a link such as My domains. 转到此页面,然后查找名为区域文件DNS 记录高级配置等名称的链接。Go to that page and then look for a link that is named something like Zone file, DNS Records, or Advanced configuration.

以下屏幕截图是 DNS 记录页的一个示例:The following screenshot is an example of a DNS records page:

示例 DNS 记录页

在示例屏幕截图中,选择“添加”来创建记录。 In the example screenshot, you select Add to create a record. 某些提供商提供了不同的链接来添加不同的记录类型。Some providers have different links to add different record types. 同样,请查阅提供商的文档。Again, consult the provider's documentation.

Note

对于某些提供商(例如 GoDaddy),在选择单独的“保存更改”链接之前,对 DNS 记录的更改不会生效 。For certain providers, such as GoDaddy, changes to DNS records don't become effective until you select a separate Save Changes link.

创建域验证记录Create domain verification record

若要验证域所有权,请添加 TXT 记录。To verify domain ownership, Add a TXT record. TXT 记录从 awverify.<subdomain> 映射到 <appname>.chinacloudsites.cn 。The TXT record maps from awverify.<subdomain> to <appname>.chinacloudsites.cn.

你需要的 TXT 记录取决于要迁移的 DNS 记录。The TXT record you need depends on the DNS record you want to migrate. 有关示例,请参阅下表(@ 通常表示根域):For examples, see the following table (@ typically represents the root domain):

DNS 记录示例DNS record example TXT 主机TXT Host TXT 值TXT Value
@(根)@ (root) awverify awverify <appname>.chinacloudsites.cn<appname>.chinacloudsites.cn
www(子域)www (sub) awverify.www awverify.www <appname>.chinacloudsites.cn<appname>.chinacloudsites.cn
*(通配符)* (wildcard) awverify.* awverify.* <appname>.chinacloudsites.cn<appname>.chinacloudsites.cn

在 DNS 记录页中,记下要迁移的 DNS 名称的记录类型。In your DNS records page, note the record type of the DNS name you want to migrate. 应用服务支持来自 CNAME 和 A 记录的映射。App Service supports mappings from CNAME and A records.

Note

对于某些提供程序(如 CloudFlare),awverify.* 不是有效记录。For certain providers, such as CloudFlare, awverify.* is not a valid record. 只能改用 *Use * only instead.

Note

通配符 * 记录不会使用现有 CNAME 记录验证子域。Wildcard * records won't validate subdomains with an existing CNAME's record. 可能需要为每个子域显式创建一条 TXT 记录。You may need to explicitly create a TXT record for each subdomain.

启用应用的域Enable the domain for your app

Azure 门户中的应用页的左侧导航窗格中,选择“自定义域” 。In the Azure portal, in the left navigation of the app page, select Custom domains.

自定义域菜单

在“自定义域” 页中,选择“添加主机名” 旁的 + 图标 。In the Custom domains page, select the + icon next to Add hostname.

添加主机名

键入已添加 TXT 记录的完全限定的域名,如 www.contoso.comType the fully qualified domain name that you added the TXT record for, such as www.contoso.com. 对于通配符域(如 *.contoso.com),可以使用与通配符域匹配的任何 DNS 名称。For a wildcard domain (like *.contoso.com), you can use any DNS name that matches the wildcard domain.

选择“验证”。 Select Validate.

“添加主机名”按钮会被激活。 The Add hostname button is activated.

请确保“主机名记录类型” 设置为你想要迁移的 DNS 记录类型。Make sure that Hostname record type is set to the DNS record type you want to migrate.

选择“添加主机名” 。Select Add hostname.

将 DNS 名称添加到应用

新主机名可能需要经过一段时间后才会反映在应用的“自定义域”页中。 It might take some time for the new hostname to be reflected in the app's Custom domains page. 请尝试刷新浏览器来更新数据。Try refreshing the browser to update the data.

已添加 CNAME 记录

你的自定义 DNS 名称现已在 Azure 应用中启用。Your custom DNS name is now enabled in your Azure app.

重新映射活动 DNS 名称Remap the active DNS name

唯一需要做的是重新映射活动 DNS 记录以指向应用服务。The only thing left to do is remapping your active DNS record to point to App Service. 现在,它仍然指向旧站点。Right now, it still points to your old site.

复制应用的 IP 地址(仅限 A 记录)Copy the app's IP address (A record only)

如果你要重新映射 CNAME 记录,请跳过此部分。If you are remapping a CNAME record, skip this section.

若要重新映射 A 记录,需要应用服务应用的外部 IP 地址,此地址显示在“自定义域” 页中。To remap an A record, you need the App Service app's external IP address, which is shown in the Custom domains page.

通过选择右上角的 X 关闭“添加主机名” 页。Close the Add hostname page by selecting X in the upper-right corner.

在“自定义域”页中,复制应用的 IP 地址。 In the Custom domains page, copy the app's IP address.

在门户中导航到 Azure 应用

更新 DNS 记录Update the DNS record

返回到域提供商的 DNS 记录页,选择要重新映射的 DNS 记录。Back in the DNS records page of your domain provider, select the DNS record to remap.

对于 contoso.com 根域示例,重新映射 A 或 CNAME 记录,如下表中的示例所示:For the contoso.com root domain example, remap the A or CNAME record like the examples in the following table:

FQDN 示例FQDN example 记录类型Record type 主机Host ValueValue
contoso.com (root)contoso.com (root) AA @ 通过复制应用的 IP 地址获得的 IP 地址IP address from Copy the app's IP address
www.contoso.com (sub)www.contoso.com (sub) CNAMECNAME www <appname>.chinacloudsites.cn<appname>.chinacloudsites.cn
*.contoso.com(通配符域)*.contoso.com (wildcard) CNAMECNAME * <appname>.chinacloudsites.cn<appname>.chinacloudsites.cn

保存设置。Save your settings.

在 DNS 传播发生后,DNS 查询应立即开始解析应用服务应用。DNS queries should start resolving to your App Service app immediately after DNS propagation happens.

后续步骤Next steps

了解如何将自定义 SSL 证书绑定到应用服务。Learn how to bind a custom SSL certificate to App Service.