快速入门:使用 Azure 门户创建流量管理器配置文件Quickstart: Create a Traffic Manager profile using the Azure portal

本快速入门介绍如何创建流量管理器配置文件,以便实现 Web 应用程序的高度可用性。This quickstart describes how to create a Traffic Manager profile that delivers high availability for your web application.

本快速入门介绍 Web 应用程序的两个实例。In this quickstart, you'll read about two instances of a web application. 每个实例在不同的 Azure 区域运行。Each of them is running in a different Azure region. 需根据终结点优先级创建流量管理器配置文件。You'll create a Traffic Manager profile based on endpoint priority. 此配置文件将用户流量定向到运行 Web 应用程序的主站点。The profile directs user traffic to the primary site running the web application. 流量管理器持续监视 Web 应用程序。Traffic Manager continuously monitors the web application. 如果主站点不可用,它会提供目标为备份站点的自动故障转移。If the primary site is unavailable, it provides automatic failover to the backup site.

如果还没有 Azure 订阅,请现在就创建一个试用帐户If you don't have an Azure subscription, create a trial account now.

登录 AzureSign in to Azure

登录到 Azure 门户Sign in to the Azure portal.

先决条件Prerequisites

本快速入门需要两个部署在两个不同的 Azure 区域(中国东部和中国北部)的 Web 应用程序实例。 For this quickstart, you'll need two instances of a web application deployed in two different Azure regions (China East and China North). 每个都可以充当流量管理器的主终结点和故障转移终结点。Each will serve as primary and failover endpoints for Traffic Manager.

  1. 在屏幕的左上方,选择“创建资源” > “Web + 移动” > “Web 应用”。On the upper-left side of the screen, select Create a resource > Web + Mobile > Web App.

  2. 在“Web 应用”中,输入或选择以下设置: In Web App, enter, or select these settings:

    设置Setting Value
    应用程序名称App name 输入 Web 应用的唯一名称。Enter a unique name for your web app.
    订阅Subscription 选择要将 Web 应用应用到其中的订阅。Select the subscription you want the web app applied to.
    资源组Resource Group 选择“新建”,然后输入 myResourceGroupTM1Select Create new, and enter myResourceGroupTM1.
  3. 选择“应用服务计划/位置”。 Select App Service plan/Location.

  4. 在“应用服务计划” 中,选择“新建” 。In App Service plan, select Create new.

  5. 在“应用服务计划”中,输入或选择以下设置: In New App Service Plan, enter, or select these settings:

    设置Setting Value
    应用服务计划App Service plan 输入 myAppServicePlanChinaEastEnter myAppServicePlanChinaEast.
    位置Location 中国东部China East
    定价层Pricing tier S1 标准S1 Standard
  6. 选择“确定” 。Select OK.

  7. 在“Web 应用”中,选择“创建” 。 In Web App, select Create. Web 应用在成功部署后会创建默认的网站。When the Web App successfully deploys, it creates a default web site.

  8. 若要在另一 Azure 区域创建另一个网站,请使用以下设置重复步骤 1-7:To create a second website in a different Azure region, repeat steps 1-7 with these settings:

    设置Setting Value
    名称Name 输入 Web 应用的唯一名称。Enter a unique name for your web app.
    订阅Subscription 选择要将 Web 应用应用到其中的订阅。Select the subscription you want the web app applied to.
    资源组Resource group 选择“新建” ,然后输入 myResourceGroupTM2Select Create new, and then enter myResourceGroupTM2.
    应用服务计划/位置App Service plan/Location 输入 myAppServicePlanChinaNorthEnter myAppServicePlanChinaNorth.
    位置Location 中国北部China North
    定价层Pricing tier S1 标准S1 Standard

创建流量管理器配置文件Create a Traffic Manager profile

创建根据终结点优先级定向用户流量的流量管理器配置文件。Create a Traffic Manager profile that directs user traffic based on endpoint priority.

  1. 在屏幕左上方,选择“创建资源” > “网络” > “全部查看” > “流量管理器配置文件” 。On the upper-left side of the screen, select Create a resource > Networking > See All > Traffic Manager profile.

  2. 在“创建流量管理器配置文件”中,输入或选择以下设置: In the Create Traffic Manager profile, enter, or select these settings:

    设置Setting Value
    名称Name 为流量管理器配置文件输入唯一名称。Enter a unique name for your Traffic Manager profile.
    路由方法Routing method 选择“优先级”。 Select Priority.
    订阅Subscription 选择要将流量管理器配置文件应用到其中的订阅。Select the subscription you want the traffic manager profile applied to.
    资源组Resource group 选择“myResourceGroupTM1” 。Select myResourceGroupTM1.
    位置Location 此设置是指资源组的位置。This setting refers to the location of the resource group. 它对将要全局部署的流量管理器配置文件没有影响。It has no effect on the Traffic Manager profile that will be deployed globally.
  3. 选择“创建” 。Select Create.

添加流量管理器终结点Add Traffic Manager endpoints

将“中国东部”区域的网站添加为用于路由所有用户流量的主终结点。 Add the website in the China East as primary endpoint to route all the user traffic. 将“中国北部”区域的网站添加为故障转移终结点。 Add the website in China North as a failover endpoint. 当主终结点不可用时,流量自动路由到故障转移终结点。When the primary endpoint is unavailable, traffic automatically routes to the failover endpoint.

  1. 在门户的搜索栏中,输入在上一部分创建的流量管理器配置文件名称。In the portal's search bar, enter the Traffic Manager profile name that you created in the preceding section.

  2. 从搜索结果中选择该配置文件。Select the profile from the search results.

  3. 在“流量管理器配置文件” 的“设置” 部分,选择“终结点” ,然后选择 “添加”。In Traffic Manager profile, in the Settings section, select Endpoints, and then select Add.

  4. 输入或选择以下设置:Enter, or select, these settings:

    设置Setting Value
    类型Type 选择“Azure 终结点”。 Select Azure endpoint.
    名称Name 输入 myPrimaryEndpointEnter myPrimaryEndpoint.
    目标资源类型Target resource type 选择“应用服务”。 Select App Service.
    目标资源Target resource 选择“选择应用服务” > “中国东部”。Select Choose an app service > China East.
    PriorityPriority 选择“1”。 Select 1. 如果此终结点处于正常状态,则所有流量都会转到此终结点。All traffic goes to this endpoint when it's healthy.

    将终结点添加到流量管理器配置文件的屏幕截图。

  5. 选择“确定” 。Select OK.

  6. 若要为第二个 Azure 区域创建故障转移终结点,请使用以下设置重复步骤 3 和 4:To create a failover endpoint for your second Azure region, repeat steps 3 and 4 with these settings:

    设置Setting Value
    类型Type 选择“Azure 终结点”。 Select Azure endpoint.
    名称Name 输入 myFailoverEndpointEnter myFailoverEndpoint.
    目标资源类型Target resource type 选择“应用服务”。 Select App Service.
    目标资源Target resource 选择“选择应用服务” > “中国北部”。Select Choose an app service > China North.
    PriorityPriority 选择 2Select 2. 如果主终结点不正常,则所有流量都会转到此故障转移终结点。All traffic goes to this failover endpoint if the primary endpoint is unhealthy.
  7. 选择“确定” 。Select OK.

添加完两个终结点后,它们会显示在流量管理器配置文件中。When you're done adding the two endpoints, they're displayed in Traffic Manager profile. 请注意,它们的监视状态现在为“联机” 。Notice that their monitoring status is Online now.

测试流量管理器配置文件Test Traffic Manager profile

在此部分,需检查流量管理器配置文件的域名。In this section, you'll check the domain name of your Traffic Manager profile. 此外还需将主终结点配置为不可用。You'll also configure the primary endpoint to be unavailable. 最后可以看到该 Web 应用仍然可用。Finally, you get to see that the web app is still available. 这是因为流量管理器将流量发送到故障转移终结点。It's because Traffic Manager sends the traffic to the failover endpoint.

检查 DNS 名称Check the DNS name

  1. 在门户的搜索栏中,搜索在前面部分中创建的流量管理器配置文件名称。In the portal's search bar, search for the Traffic Manager profile name that you created in the preceding section.

  2. 选择流量管理器配置文件。Select the traffic manager profile. 此时会显示“概览” 。The Overview appears.

  3. “流量管理器配置文件” 会显示新建的流量管理器配置文件的 DNS 名称。The Traffic Manager profile displays the DNS name of your newly created Traffic Manager profile.

    流量管理器 DNS 名称位置的屏幕截图

查看正在运行的流量管理器View Traffic Manager in action

  1. 在 Web 浏览器中输入流量管理器配置文件的 DNS 名称,以便查看 Web 应用的默认网站。In a web browser, enter the DNS name of your Traffic Manager profile to view your Web App's default website.

    Note

    在本快速入门方案中,所有请求都路由到主终结点。In this quickstart scenario, all requests route to the primary endpoint. 它设置为“优先级 1”。 It is set to Priority 1.

    用于确认流量管理器配置文件可用性的网页的屏幕截图

  2. 若要查看流量管理器故障转移如何进行,请禁用主站点:To view Traffic Manager failover in action, disable your primary site:

    1. 在“流量管理器配置文件”页的“概览”部分,选择“myPrimaryEndpoint”。 In the Traffic Manager Profile page, from the Overview section, select myPrimaryEndpoint.
    2. myPrimaryEndpoint 中选择“禁用” > “保存”。 In myPrimaryEndpoint, select Disabled > Save.
    3. 关闭 myPrimaryEndpointClose myPrimaryEndpoint. 请注意,状态现在为“禁用”。 Notice that the status is Disabled now.
  3. 从上一步复制流量管理器配置文件的 DNS 名称即可在新的 Web 浏览器会话中查看网站。Copy the DNS name of your Traffic Manager Profile from the preceding step to view the website in a new web browser session.

  4. 验证 Web 应用是否仍然可用。Verify that the web app is still available.

主终结点不可用,因此系统将你路由到故障转移终结点。The primary endpoint isn't available, so you were routed to the failover endpoint.

清理资源Clean up resources

完成后,请删除资源组、Web 应用程序以及所有相关资源。When you're done, delete the resource groups, web applications, and all related resources. 为此,请从仪表板选择每个单独的项,然后在每个页面的顶部选择“删除”。 To do so, select each individual item from your dashboard and select Delete at the top of each page.

后续步骤Next steps

本快速入门介绍了如何创建流量管理器配置文件,In this quickstart, you created a Traffic Manager profile. 以便将用户流量定向到高度可用的 Web 应用程序。It allows you to direct user traffic for high-availability web applications. 若要详细了解如何路由流量,请继续学习流量管理器教程。To learn more about routing traffic, continue to the Traffic Manager tutorials.