将自定义域映射到 Azure Blob 存储终结点Map a custom domain to an Azure Blob Storage endpoint

可以将自定义域映射到 blob 服务终结点或静态网站终结点。You can map a custom domain to a blob service endpoint or a static website endpoint.

备注

具有分层命名空间 (Azure Data Lake Storage Gen2) 的帐户尚不支持此功能。This feature is not yet supported in accounts that have a hierarchical namespace (Azure Data Lake Storage Gen2). 若要了解详细信息,请参阅 Azure Data Lake Storage Gen2 中可用的 Blob 存储功能To learn more, see Blob storage features available in Azure Data Lake Storage Gen2.

备注

这种映射仅适用于子域(例如:www.contoso.com)。This mapping works only for subdomains (for example: www.contoso.com).

在启用仅限 HTTP 的情况下映射自定义域Map a custom domain with only HTTP enabled

此方法更简单,但要启用仅限 HTTP 的访问。This approach is easier, but enables only HTTP access.

映射自定义域Map a custom domain

重要

在完成配置的过程中,用户会有短暂的时间无法使用你的自定义域。Your custom domain will be briefly unavailable to users while you complete the configuration. 如果域当前支持的某个应用程序所附带的服务级别协议 (SLA) 要求停机时间为零,请遵循本文的在不停机的情况下映射自定义域部分中的步骤,以确保用户在 DNS 映射期间能够访问该域。If your domain currently supports an application with a service-level agreement (SLA) that requires zero downtime, then follow the steps in the Map a custom domain with zero downtime section of this article to ensure that users can access your domain while the DNS mapping takes place.

如果你不担心域有短暂的时间对用户不可用,请执行以下步骤。If you are unconcerned that the domain is briefly unavailable to your users, follow these steps.

✔️步骤 1:获取存储终结点的主机名。Step 1: Get the host name of your storage endpoint.

✔️步骤 2:在域提供商的配合下创建规范名称 (CNAME) 记录。Step 2: Create a canonical name (CNAME) record with your domain provider.

✔️步骤 3:将自定义域注册到 Azure。Step 3: Register the custom domain with Azure.

✔️步骤 4:测试自定义域。Step 4: Test your custom domain.

步骤 1:获取存储终结点的主机名Step 1: Get the host name of your storage endpoint

主机名是没有协议标识符和尾部斜杠的存储终结点 URL。The host name is the storage endpoint URL without the protocol identifier and the trailing slash.

  1. Azure 门户中转到自己的存储帐户。In the Azure portal, go to your storage account.

  2. 在菜单窗格中的“设置”下,选择“属性”。 In the menu pane, under Settings, select Properties.

  3. 主 Blob 服务终结点主静态网站终结点的值复制到文本文件。Copy the value of the Primary Blob Service Endpoint or the Primary static website endpoint to a text file.

  4. 从该字符串中删除协议标识符(例如 HTTPS)和尾部斜杠。 Remove the protocol identifier (e.g., HTTPS) and the trailing slash from that string. 下表提供了一些示例。The following table contains examples.

    终结点的类型Type of endpoint endpointendpoint 主机名host name
    Blob 服务blob service https://mystorageaccount.blob.core.chinacloudapi.cn/ mystorageaccount.blob.core.chinacloudapi.cn
    静态网站static website https://mystorageaccount.z4.web.core.chinacloudapi.cn/ mystorageaccount.z4.web.core.chinacloudapi.cn

    请设置此值供稍后使用。Set this value aside for later.

步骤 2:在域提供商的配合下创建规范名称 (CNAME) 记录Step 2: Create a canonical name (CNAME) record with your domain provider

创建一条 CNAME 记录,以指向主机名。Create a CNAME record to point to your host name. CNAME 记录是一种 DNS 记录,用于将源域名映射到目标域名。A CNAME record is a type of DNS record that maps a source domain name to a destination domain name.

  1. 登录到域注册机构的网站,并转到用于管理 DNS 设置的页面。Sign in to your domain registrar's website, and then go to the page for managing DNS setting.

    可在名为“域名”、“DNS”或“名称服务器管理”的部分中找到该页。 You might find the page in a section named Domain Name, DNS, or Name Server Management.

  2. 找到用于管理 CNAME 记录的部分。Find the section for managing CNAME records.

    可能需要转到高级设置页,并查找“CNAME”、“别名”或“子域”。 You might have to go to an advanced settings page and look for CNAME, Alias, or Subdomains.

  3. 创建 CNAME 记录。Create a CNAME record. 在该记录中提供以下项:As part of that record, provide the following items:

步骤 3:将自定义域注册到 AzureStep 3: Register your custom domain with Azure

  1. Azure 门户中转到自己的存储帐户。In the Azure portal, go to your storage account.

  2. 在菜单窗格中的“Blob 服务”下,选择“自定义域”。 In the menu pane, under Blob Service, select Custom domain.

    自定义域选项custom domain option

    此时会打开“自定义域”窗格。 The Custom domain pane opens.

  3. 在“域名”文本框中输入自定义域的名称,包括子域 In the Domain name text box, enter the name of your custom domain, including the subdomain

    例如,如果域是 contoso.com,子域别名是 www,请输入 www.contoso.comFor example, if your domain is contoso.com and your subdomain alias is www, enter www.contoso.com. 如果子域是 photos,请输入 photos.contoso.comIf your subdomain is photos, enter photos.contoso.com.

  4. 若要注册自定义域,请选择“保存”按钮。 To register the custom domain, choose the Save button.

    CNAME 记录通过域名服务器 (DNS) 传播后,如果用户具有相应的权限,则他们可以使用自定义域查看 Blob 数据。After the CNAME record has propagated through the Domain Name Servers (DNS), and if your users have the appropriate permissions, they can view blob data by using the custom domain.

步骤 4:测试自定义域Step 4: Test your custom domain

若要确认自定义域是否映射到了 Blob 服务终结点,请在存储帐户中的公共容器内创建一个 Blob。To confirm that your custom domain is mapped to your blob service endpoint, create a blob in a public container within your storage account. 然后在 Web 浏览器中,使用以下格式的 URI 来访问该 Blob:http://<subdomain.customdomain>/<mycontainer>/<myblob>Then, in a web browser, access the blob by using a URI in the following format: http://<subdomain.customdomain>/<mycontainer>/<myblob>

例如,若要访问 photos.contoso.com 自定义子域中的 myforms 容器内的 Web 窗体:可使用以下 URI:http://photos.contoso.com/myforms/applicationform.htmFor example, to access a web form in the myforms container in the photos.contoso.com custom subdomain, you might use the following URI: http://photos.contoso.com/myforms/applicationform.htm

在不停机的情况下映射自定义域Map a custom domain with zero downtime

备注

如果你不担心域有短暂的时间对用户不可用,请考虑执行本文的映射自定义域部分中的步骤。If you are unconcerned that the domain is briefly unavailable to your users, then consider following the steps in the Map a custom domain section of this article. 这是一种更简单的方法,且步骤更少。It's a simpler approach with fewer steps.

如果域当前支持的某个应用程序所附带的服务级别协议 (SLA) 要求停机时间为零,请执行这些步骤,以确保用户在 DNS 映射期间能够访问该域。If your domain currently supports an application with a service-level agreement (SLA) that requires zero downtime, then follow these steps to ensure that users can access your domain while the DNS mapping takes place.

✔️步骤 1:获取存储终结点的主机名。Step 1: Get the host name of your storage endpoint.

✔️步骤 2:在域提供商的配合下创建一条中间规范名称 (CNAME) 记录。Step 2: Create a intermediary canonical name (CNAME) record with your domain provider.

✔️步骤 3:将自定义域预先注册到 Azure。Step 3: Pre-register the custom domain with Azure.

✔️步骤 4:在域提供商的配合下创建 CNAME 记录。Step 4: Create a CNAME record with your domain provider.

✔️步骤 5:测试自定义域。Step 5: Test your custom domain.

步骤 1:获取存储终结点的主机名Step 1: Get the host name of your storage endpoint

主机名是没有协议标识符和尾部斜杠的存储终结点 URL。The host name is the storage endpoint URL without the protocol identifier and the trailing slash.

  1. Azure 门户中转到自己的存储帐户。In the Azure portal, go to your storage account.

  2. 在菜单窗格中的“设置”下,选择“属性”。 In the menu pane, under Settings, select Properties.

  3. 主 Blob 服务终结点主静态网站终结点的值复制到文本文件。Copy the value of the Primary Blob Service Endpoint or the Primary static website endpoint to a text file.

  4. 从该字符串中删除协议标识符(例如 HTTPS)和尾部斜杠。 Remove the protocol identifier (e.g., HTTPS) and the trailing slash from that string. 下表提供了一些示例。The following table contains examples.

    终结点的类型Type of endpoint endpointendpoint 主机名host name
    Blob 服务blob service https://mystorageaccount.blob.core.chinacloudapi.cn/ mystorageaccount.blob.core.chinacloudapi.cn
    静态网站static website https://mystorageaccount.z4.web.core.chinacloudapi.cn/ mystorageaccount.z4.web.core.chinacloudapi.cn

    请设置此值供稍后使用。Set this value aside for later.

步骤 2:在域提供商的配合下创建一条中间规范名称 (CNAME) 记录Step 2: Create a intermediary canonical name (CNAME) record with your domain provider

创建一条临时 CNAME 记录,以指向主机名。Create a temporary CNAME record to point to your host name. CNAME 记录是一种 DNS 记录,用于将源域名映射到目标域名。A CNAME record is a type of DNS record that maps a source domain name to a destination domain name.

  1. 登录到域注册机构的网站,并转到用于管理 DNS 设置的页面。Sign in to your domain registrar's website, and then go to the page for managing DNS setting.

    可在名为“域名”、“DNS”或“名称服务器管理”的部分中找到该页。 You might find the page in a section named Domain Name, DNS, or Name Server Management.

  2. 找到用于管理 CNAME 记录的部分。Find the section for managing CNAME records.

    可能需要转到高级设置页,并查找“CNAME”、“别名”或“子域”。 You might have to go to an advanced settings page and look for CNAME, Alias, or Subdomains.

  3. 创建 CNAME 记录。Create a CNAME record. 在该记录中提供以下项:As part of that record, provide the following items:

    • 子域别名,例如 wwwphotosThe subdomain alias such as www or photos. 必须指定子域,不支持根域。The subdomain is required, root domains are not supported.

      asverify 子域添加到别名。Add the asverify subdomain to the alias. 例如: asverify.wwwasverify.photosFor example: asverify.www or asverify.photos.

    • 在本文前面的获取存储终结点的主机名部分获取的主机名。The host name that you obtained in the Get the host name of your storage endpoint section earlier in this article.

      将子域 asverify 添加到主机名。Add the subdomain asverify to the host name. 例如:asverify.mystorageaccount.blob.core.chinacloudapi.cnFor example: asverify.mystorageaccount.blob.core.chinacloudapi.cn.

  4. 若要注册自定义域,请选择“保存”按钮。 To register the custom domain, choose the Save button.

    如果注册成功,则门户会通知存储帐户已成功更新。If the registration is successful, the portal notifies you that your storage account was successfully updated. 自定义域已由 Azure 验证,但发往域的流量尚未路由到存储帐户。Your custom domain has been verified by Azure, but traffic to your domain is not yet being routed to your storage account.

步骤 3:将自定义域预先注册到 AzureStep 3: Pre-register your custom domain with Azure

将自定义域预先注册到 Azure 后,可使 Azure 识别该自定义域,且无需修改该域的 DNS 记录。When you pre-register your custom domain with Azure, you permit Azure to recognize your custom domain without having to modify the DNS record for the domain. 这样,在修改该域的 DNS 记录时,它会映射到 Blob 终结点,并且不会出现停机。That way, when you do modify the DNS record for the domain, it will be mapped to the blob endpoint with no downtime.

  1. Azure 门户中转到自己的存储帐户。In the Azure portal, go to your storage account.

  2. 在菜单窗格中的“Blob 服务”下,选择“自定义域”。 In the menu pane, under Blob Service, select Custom domain.

    自定义域选项custom domain option

    此时会打开“自定义域”窗格。 The Custom domain pane opens.

  3. 在“域名”文本框中输入自定义域的名称,包括子域 In the Domain name text box, enter the name of your custom domain, including the subdomain

    例如,如果域是 contoso.com,子域别名是 www,请输入 www.contoso.comFor example, if your domain is contoso.com and your subdomain alias is www, enter www.contoso.com. 如果子域是 photos,请输入 photos.contoso.comIf your subdomain is photos, enter photos.contoso.com.

  4. 选中“使用间接 CNAME 验证”复选框。 Select the Use indirect CNAME validation check box.

  5. 若要注册自定义域,请选择“保存”按钮。 To register the custom domain, choose the Save button.

    CNAME 记录通过域名服务器 (DNS) 传播后,如果用户具有相应的权限,则他们可以使用自定义域查看 Blob 数据。After the CNAME record has propagated through the Domain Name Servers (DNS), and if your users have the appropriate permissions, they can view blob data by using the custom domain.

步骤 4:在域提供商的配合下创建 CNAME 记录Step 4: Create a CNAME record with your domain provider

创建一条临时 CNAME 记录,以指向主机名。Create a temporary CNAME record to point to your host name.

  1. 登录到域注册机构的网站,并转到用于管理 DNS 设置的页面。Sign in to your domain registrar's website, and then go to the page for managing DNS setting.

    可在名为“域名”、“DNS”或“名称服务器管理”的部分中找到该页。 You might find the page in a section named Domain Name, DNS, or Name Server Management.

  2. 找到用于管理 CNAME 记录的部分。Find the section for managing CNAME records.

    可能需要转到高级设置页,并查找“CNAME”、“别名”或“子域”。 You might have to go to an advanced settings page and look for CNAME, Alias, or Subdomains.

  3. 创建 CNAME 记录。Create a CNAME record. 在该记录中提供以下项:As part of that record, provide the following items:

步骤 5:测试自定义域Step 5: Test your custom domain

若要确认自定义域是否映射到了 Blob 服务终结点,请在存储帐户中的公共容器内创建一个 Blob。To confirm that your custom domain is mapped to your blob service endpoint, create a blob in a public container within your storage account. 然后在 Web 浏览器中,使用以下格式的 URI 来访问该 Blob:http://<subdomain.customdomain>/<mycontainer>/<myblob>Then, in a web browser, access the blob by using a URI in the following format: http://<subdomain.customdomain>/<mycontainer>/<myblob>

例如,若要访问 photos.contoso.com 自定义子域中的 myforms 容器内的 Web 窗体:可使用以下 URI:http://photos.contoso.com/myforms/applicationform.htmFor example, to access a web form in the myforms container in the photos.contoso.com custom subdomain, you might use the following URI: http://photos.contoso.com/myforms/applicationform.htm

删除自定义域映射Remove a custom domain mapping

若要删除自定义域映射,请取消注册自定义域。To remove a custom domain mapping, deregister the custom domain. 使用以下过程之一。Use one of the following procedures.

若要删除自定义域设置,请执行以下操作:To remove the custom domain setting, do the following:

  1. Azure 门户中转到自己的存储帐户。In the Azure portal, go to your storage account.

  2. 在菜单窗格中的“Blob 服务”下,选择“自定义域”。 In the menu pane, under Blob Service, select Custom domain.
    此时会打开“自定义域”窗格。 The Custom domain pane opens.

  3. 清除包含自定义域名的文本框的内容。Clear the contents of the text box that contains your custom domain name.

  4. 选择“保存”按钮。 Select the Save button.

成功删除自定义域后,会看到一条门户通知,指出存储帐户已成功更新After the custom domain has been removed successfully, you will see a portal notification that your storage account was successfully updated

后续步骤Next steps