您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

为 Azure 应用服务购买自定义域名Buy a custom domain name for Azure App Service

应用服务域是直接在 Azure 中管理的自定义域。App Service domains are custom domains that are managed directly in Azure. 使用这些域可以轻松管理 Azure 应用服务的自定义域。They make it easy to manage custom domains for Azure App Service. 本教程介绍如何购买应用服务域并将 DNS 名称分配到 Azure 应用服务。This tutorial shows you how to buy an App Service domain and assign DNS names to Azure App Service.

对于 Azure VM 或 Azure 存储,请查看Assign App Service domain to Azure VM or Azure Storage(将应用服务分配到 Azure VM 或 Azure 存储)。For Azure VM or Azure Storage, see Assign App Service domain to Azure VM or Azure Storage. 对于云服务,请查看为 Azure 云服务配置自定义域名For Cloud Services, see Configuring a custom domain name for an Azure cloud service.

先决条件Prerequisites

完成本教程:To complete this tutorial:

购买应用服务域Buy an App Service domain

有关应用服务域的定价信息,请访问 应用服务定价页 并向下滚动到 "应用服务域"。For pricing information on App Service domains, visit the App Service Pricing page and scroll down to App Service Domain.

  1. 打开 Azure 门户,然后使用 Azure 帐户登录。Open the Azure portal and sign in with your Azure account.

  2. 在搜索栏中,搜索并选择 " 应用服务域"。In the search bar, search for and select App Service Domains.

    门户导航到 Azure App Service 域

  3. 应用服务域 视图中,单击 " 添加"。In the App Service Domains view, click Add.

    单击 "在应用服务域中添加"

  4. 选择 " 单击以尝试更新版本的应用服务域创建体验"Select Click to try the newer version of the App Service Domains create experience.

    创建具有新体验的应用服务域

“基本信息”选项卡Basics tab

  1. 在 " 基本 信息" 选项卡中,使用下表配置设置:In the Basics tab, configure the settings using the following table:

    设置Setting 描述Description
    订阅Subscription 用于购买域的订阅。The subscription to use to buy the domain.
    资源组Resource Group 要放置域的资源组。The resource group to put the domain in. 例如,你的应用所在的资源组。For example, the resource group your app is in.
    Domain 键入所需的域。Type the domain you want. 例如, contoso.comFor example, contoso.com. 如果所需的域不可用,可以从可用域的建议列表中进行选择,或尝试其他域。If the domain you want is not available, you can select from a list of suggestions of available domains, or try a different domain.

    备注

    应用服务域支持以下顶级域:com、net、co.uk、org、nl、in、biz、org.uk 和 co.in。The following top-level domains are supported by App Service domains: com, net, co.uk, org, nl, in, biz, org.uk, and co.in.

  2. 完成后,单击 " 下一步:联系人信息"。When finished, click Next: Contact information.

联系人信息选项卡Contact information tab

  1. 为域注册提供 ICANN 所需的信息。Supply your information as required by ICANN for the domain registration.

    请务必尽量准确填写所有必填字段。It is important that you fill out all required fields with as much accuracy as possible. 联系信息的数据不正确可能会导致无法购买域。Incorrect data for contact information can result in failure to buy the domain.

  2. 完成后,单击 " 下一步:高级"。When finished, click Next: Advanced.

高级选项卡Advanced tab

  1. 在 " 高级 " 选项卡中,配置可选设置:In the Advanced tab, configure the optional settings:

    设置Setting 描述Description
    自动续订Auto renewal 默认情况下启用。Enabled by default. 应用服务域会以一年的增量注册到你。Your App Service domain is registered to you at one-year increments. 自动续订确保你的域注册不会过期,并且你保留域的所有权。Auto renewal makes sure that your domain registration doesn't expire and that you retain ownership of the domain. 续订时,Azure 订阅会自动向每年的域注册费用收费。Your Azure subscription is automatically charged the yearly domain registration fee at the time of renewal. 若要选择退出,请选择 " 禁用"。To opt out, select Disable. 如果禁用自动续订,则可以 手动续订If auto-renewal is disabled, you can renew it manually.
    隐私保护Privacy protection 默认情况下启用。Enabled by default. 隐私保护将从 WHOIS 数据库中隐藏域注册联系信息。Privacy protection hides your domain registration contact information from the WHOIS database. 隐私保护已包含在每年的域注册费中。Privacy protection is already included in the yearly domain registration fee. 若要选择退出,请选择 " 禁用"。To opt out, select Disable.
  2. 完成后,单击 " 下一步:标记"。When finished, click Next: Tags.

完成Finish

  1. 在 " 标记 " 选项卡中,为应用服务域设置所需的标记。In the Tags tab, set the tags you want for your App Service domain. 使用应用服务域不需要标记,但它是 Azure 中的一项功能,可帮助你管理资源Tagging is not required for using App Service domains, but is a feature in Azure that helps you manage your resources.

  2. 单击 " 下一步":查看 + 创建Click Next: Review + create.

  3. 在 " 查看 " 和 "创建" 选项卡中,查看域顺序。In the Review + create tab, review your domain order. 完成后,单击“创建”。When finished, click Create.

    备注

    应用服务域使用 GoDaddy 进行域注册,使用 Azure DNS 来托管域。App Service Domains use GoDaddy for domain registration and Azure DNS to host the domains. 除每年的域注册费外,Azure DNS 适用的使用费用。In addition to the yearly domain registration fee, usage charges for Azure DNS apply. 有关信息,请参阅 Azure DNS 定价For information, see Azure DNS Pricing.

  4. 域注册完成后,会看到 " 中转到资源 " 按钮。When the domain registration is complete, you see a Go to resource button. 选择它以查看其管理页面。Select it to see it's management page.

    已创建应用服务域。

你现在已准备好将应用服务应用分配到此自定义域。You're now ready to assign an App Service app to this custom domain.

准备应用Prepare the app

若要将自定义 DNS 名称映射到 Web 应用,Web 应用的应用服务计划必须位于付费层(Azure Functions 的共享、基本、标准、高级或消耗层)。To map a custom DNS name to a web app, the web app's App Service plan must be a paid tier (Shared, Basic, Standard, Premium, or Consumption for Azure Functions). 在此步骤中,需确保应用服务计划位于受支持的定价层。In this step, you make sure that the App Service app is in the supported pricing tier.

备注

应用服务免费和共享(预览)托管计划是基本层,与其他应用服务应用在相同的 Azure 虚拟机上运行。App Service Free and Shared (preview) hosting plans are base tiers that run on the same Azure virtual machines as other App Service apps. 某些应用可能属于其他客户。Some apps might belong to other customers. 这些层仅旨在用于开发和测试目的。These tiers are intended to be used only for development and testing purposes.

  1. 在顶部搜索栏中,搜索并选择 " 应用服务"。From the top search bar, search for and select App Services.

    搜索应用服务

  2. 选择应用程序的名称。Select the name of the app.

    在门户中导航到 Azure 应用

    将看到应用服务应用的管理页。You see the management page of the App Service app.

检查定价层Check the pricing tier

  1. 在应用页的左侧导航窗格中,向下滚动到“设置”部分,然后选择“增加(应用服务计划)”。In the left navigation of the app page, scroll to the Settings section and select Scale up (App Service plan).

    扩展菜单

  2. 蓝色边框突出显示了应用的当前层。The app's current tier is highlighted by a blue border. 检查以确保应用不在 F1 层中。Check to make sure that the app is not in the F1 tier. F1 层不支持自定义 DNS。Custom DNS is not supported in the F1 tier.

    ) 选择 (应用服务计划的应用页面左侧导航菜单的屏幕截图。

  3. 如果应用服务计划不在 F1 层中,请关闭“纵向扩展”页并跳转到 购买域If the App Service plan is not in the F1 tier, close the Scale up page and skip to Buy the domain.

增加应用服务计划Scale up the App Service plan

  1. 选择任何非免费层(D1B1B2B3,或“生产”类别中的任何层)。Select any of the non-free tiers (D1, B1, B2, B3, or any tier in the Production category). 有关其他选项,请单击“查看其他选项”。For additional options, click See additional options.

  2. 单击“应用” 。Click Apply.

    生产类别中的自定义域定价层的屏幕截图,其中突出显示了 "生产" 选项卡、B1 计划和 "应用" 按钮。

    看到以下通知时,说明缩放操作已完成。When you see the following notification, the scale operation is complete.

    缩放操作确认

将应用服务域映射到你的应用Map App Service domain to your app

可以轻松地将应用服务域中的主机名映射到应用服务应用,只要它在同一订阅中即可。It's easy to map a hostname in your App Service domain to an App Service app, as long as it's in the same subscription. 直接在应用中映射应用服务域或其任何子域,Azure 将为你创建所需的 DNS 记录。You map the App Service domain or any of its subdomain directly in your app, and Azure creates the necessary DNS records for you.

备注

如果域和应用在不同的订阅中,则可以将应用服务域映射到应用,就像 映射外部购买的域一样。If the domain and the app are in different subscriptions, you map the App Service domain to the app just like mapping an externally purchased domain. 在这种情况下,Azure DNS 是外部域提供程序,需要 手动添加所需的 DNS 记录In this case, Azure DNS is the external domain provider, and you need to add the required DNS records manually.

映射域Map the domain

  1. 在应用页面的左侧导航栏中,滚动到 " 设置 " 部分,并选择 " 自定义域"。In the left navigation of the app page, scroll to the Settings section and select Custom domains.

    显示“自定义域”菜单的屏幕截图。

  2. 选择“添加自定义域”。Select Add custom domain.

    显示“添加主机名”项的屏幕截图。

  3. 键入应用服务域 (例如 contoso.com) 或子域 (如 www.contoso.com) ,然后单击 " 验证"。Type the App Service domain (such as contoso.com) or a subdomain (such as www.contoso.com) and click Validate.

    备注

    如果在应用服务域名中进行了键入错误,则会在页面底部显示验证错误,告诉你缺少某些 DNS 记录。If you made a typo in the App Service domain name, a verification error appears at the bottom of the page to tell you that you're missing some DNS records. 无需手动添加应用服务域的这些记录。You don't need to add these records manually for an App Service domain. 只需确保正确键入域名,再单击 " 验证 "。Just make sure that you type the domain name correctly and click Validate again.

    显示验证错误的屏幕截图。

  4. 接受 Hostname 记录类型 ,然后单击 " 添加自定义域"。Accept the Hostname record type and click Add custom domain.

    显示“添加自定义域”按钮的屏幕截图。

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

    演示如何添加 CNAME 记录的屏幕截图。

    备注

    自定义域的 " 不安全 " 标签表示该标签尚未绑定到 TLS/SSL 证书。A Not Secure label for your custom domain means that it's not yet bound to a TLS/SSL certificate. 从浏览器向自定义域发出任何 HTTPS 请求都会收到错误或警告,具体取决于浏览器。Any HTTPS request from a browser to your custom domain will receive an error or warning, depending on the browser. 若要添加 TLS 绑定,请参阅在 Azure 应用服务中使用 TLS/SSL 绑定保护自定义 DNS 名称To add a TLS binding, see Secure a custom DNS name with a TLS/SSL binding in Azure App Service.

测试自定义域Test the custom domain

若要测试自定义域,请在浏览器中导航到该自定义域。To test the custom domain, navigate to it in the browser.

续订域Renew the domain

你所购买的应用服务域自购买之日起的一年内有效。The App Service domain you bought is valid for one year from the time of purchase. 默认情况下,通过收取下一年费用的付款方式将域配置为自动续订。By default, the domain is configured to renew automatically by charging your payment method for the next year. 你可以手动续订你的域名。You can manually renew your domain name.

如果要关闭自动续订,或者手动续订域,请按照以下步骤操作。If you want to turn off automatic renewal, or if you want to manually renew your domain, follow the steps here.

  1. 在搜索栏中,搜索并选择 " 应用服务域"。In the search bar, search for and select App Service Domains.

    门户导航到 Azure App Service 域

  2. 在“应用服务域”部分,选择要配置的域。In the App Service Domains section, select the domain you want to configure.

  3. 从域的左侧导航窗格,选择“域续订”。From the left navigation of the domain, select Domain renewal. 若要停止自动续订域,请选择 " 关闭"。To stop renewing your domain automatically, select Off. 该设置将立即生效。The setting takes effect immediately.

    显示自动续订你的域的选项的屏幕截图。

    备注

    离开页面时,单击 "确定" 将忽略 "未保存的编辑将被丢弃" 错误。When navigating away from the page, disregard the "Your unsaved edits will be discarded" error by clicking OK.

若要手动续订域,选择“续订域”。To manually renew your domain, select Renew domain. 但是,此按钮在 域过期之前90天内处于非活动状态。However, this button is not active until 90 days before the domain's expiration.

如果域续订成功,则会在24小时内收到电子邮件通知。If your domain renewal is successful, you receive an email notification within 24 hours.

域过期时间When domain expires

Azure 会处理过期或过期的应用服务域,如下所示:Azure deals with expiring or expired App Service domains as follows:

  • 如果禁用自动续订:在域过期之前90天,将向你发送续订通知电子邮件,并在门户中激活 " 续订域 " 按钮。If automatic renewal is disabled: 90 days before domain expiration, a renewal notification email is sent to you and the Renew domain button is activated in the portal.
  • 如果启用自动续订:在你的域到期日期之后的那一日,Azure 将尝试为你的域名续订付费。If automatic renewal is enabled: On the day after your domain expiration date, Azure attempts to bill you for the domain name renewal.
  • 如果在自动续订期间出现错误 (例如,文件上的卡已过期) ,或者禁用了自动续订,并且你允许域过期,则 Azure 会通知你域过期,并使你的域名过期。If an error occurs during automatic renewal (for example, your card on file is expired), or if automatic renewal is disabled and you allow the domain to expire, Azure notifies you of the domain expiration and parks your domain name. 你可以 手动续订 你的域。You can manually renew your domain.
  • 在过期后的第4天和第12天,Azure 会向你发送其他通知电子邮件。On the 4th and 12th days day after expiration, Azure sends you additional notification emails. 你可以 手动续订 你的域。You can manually renew your domain.
  • 在过期后的第19天,你的域仍保持不变,但会收取兑换费。On the 19th day after expiration, your domain remains on hold but becomes subject to a redemption fee. 你可以致电客户支持人员续订你的域名,但需遵守任何适用的续订和兑换费用。You can call customer support to renew your domain name, subject to any applicable renewal and redemption fees.
  • 在过期后的第25天,Azure 将使用域名行业拍卖服务使你的域与拍卖联系。On the 25th day after expiration, Azure puts your domain up for auction with a domain name industry auction service. 你可以致电客户支持人员续订你的域名,但需遵守任何适用的续订和兑换费用。You can call customer support to renew your domain name, subject to any applicable renewal and redemption fees.
  • 过期后的30天后,你将无法再兑换你的域。On the 30th day after expiration, you're no longer able to redeem your domain.

管理自定义 DNS 记录Manage custom DNS records

在 Azure 中,可以使用 Azure DNS 管理应用服务域的 DNS 记录。In Azure, DNS records for an App Service Domain are managed using Azure DNS. 可以添加、删除和更新 DNS 记录,就像使用外部购买的域时一样。You can add, remove, and update DNS records, just like for an externally purchased domain. 管理自定义 DNS 记录:To manage custom DNS records:

  1. 在搜索栏中,搜索并选择 " 应用服务域"。In the search bar, search for and select App Service Domains.

    门户导航到 Azure App Service 域

  2. 在“应用服务域”部分,选择要配置的域。In the App Service Domains section, select the domain you want to configure.

  3. 从 " 概述 " 页中,选择 " 管理 DNS 记录"。From the Overview page, select Manage DNS records.

    显示 DNS 记录访问位置的屏幕截图。

有关如何编辑 DNS 记录的信息,请参阅如何在 Azure 门户中管理 DNS 区域For information on how to edit DNS records, see How to manage DNS Zones in the Azure portal.

取消购买(删除域)Cancel purchase (delete domain)

购买应用服务域后,可在五天内取消购买以获得全额退款。After you purchase the App Service Domain, you have five days to cancel your purchase for a full refund. 五天之后,可以删除应用服务域,但无法获得退款。After five days, you can delete the App Service Domain, but cannot receive a refund.

  1. 在搜索栏中,搜索并选择 " 应用服务域"。In the search bar, search for and select App Service Domains.

    门户导航到 Azure App Service 域

  2. 在“应用服务域”部分,选择要配置的域。In the App Service Domains section, select the domain you want to configure.

  3. 在域的左侧导航窗格中,选择 " 主机名绑定"。In the domain's left navigation, select Hostname bindings. 此处列出了所有 Azure 服务的主机名绑定。The hostname bindings from all Azure services are listed here.

    显示 "主机名绑定" 页的屏幕截图。

  4. 通过 选择 > "删除每个主机名"删除Delete each hostname binding by selecting ... > Delete. 删除所有绑定后,选择“保存”。After all the bindings are deleted, select Save.

  5. 在域的左侧导航窗格中,选择 " 概述"。In the domain's left navigation, select Overview.

  6. 如果所购买域的取消期限未过,请选择“取消购买”。If the cancellation period on the purchased domain has not elapsed, select Cancel purchase. 否则,请参阅“删除”按钮。Otherwise, you see a Delete button instead. 若要删除该域且不想要获得退款,请选择“删除”。To delete the domain without a refund, select Delete.

    显示在何处删除或取消购买的域的屏幕截图。

  7. 通过选择 "是" 确认操作。Confirm the operation by selecting Yes.

    完成该操作后,该域将从订阅中释放,可供任何人再次购买。After the operation is complete, the domain is released from your subscription and available for anyone to purchase again.

将默认 URL 定向到自定义目录Direct default URL to a custom directory

默认情况下,应用服务将 Web 请求定向到应用代码的根目录下。By default, App Service directs web requests to the root directory of your app code. 若要将它们定向到一个子目录(如 public ),请参阅 重定向到自定义目录To direct them to a subdirectory, such as public, see Redirect to a custom directory.

后续步骤Next steps

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