使用 Azure 流量管理器控制 Azure 应用服务流量Controlling Azure App Service traffic with Azure Traffic Manager

Note

本文提供了有关 Azure 流量管理器的摘要信息,因为它与 Azure 应用服务相关。This article provides summary information for Azure Traffic Manager as it relates to Azure App Service. 有关 Azure 流量管理器本身的更多信息,请访问本文结尾处的链接。More information about Azure Traffic Manager itself can be found by visiting the links at the end of this article.

简介Introduction

可以使用 Azure 流量管理器来控制如何将来自 Web 客户端的请求分发到 Azure 应用服务中的应用。You can use Azure Traffic Manager to control how requests from web clients are distributed to apps in Azure App Service. 将应用服务终结点添加到 Azure 流量管理器配置文件时,Azure 流量管理器会跟踪应用服务的状态(正在运行、已停止或已删除),以便确定那些终结点中有哪些应该接收流量。When App Service endpoints are added to an Azure Traffic Manager profile, Azure Traffic Manager keeps track of the status of your App Service apps (running, stopped, or deleted) so that it can decide which of those endpoints should receive traffic.

路由方法Routing methods

Azure 流量管理器使用四种不同的路由方法。Azure Traffic Manager uses four different routing methods. 下面的列表中介绍了与 Azure 应用服务相关时这些方法的情况。These methods are described in the following list as they pertain to Azure App Service.

  • 优先级 所有流量都使用主应用,并提供备份以防主或备份应用不可用。Priority: use a primary app for all traffic, and provide backups in case the primary or the backup apps are unavailable.
  • 加权 将流量分配到一组应用,不管是平均分配还是根据定义的权重进行分配。Weighted: distribute traffic across a set of apps, either evenly or according to weights, which you define.
  • 性能 当应用位于不同的地理位置时,请使用从最低网络延迟角度而言“最靠近的”应用。Performance: when you have apps in different geographic locations, use the "closest" app in terms of the lowest network latency.
  • 地理 根据 DNS 查询来自的地理位置将用户定向到特定的应用。Geographic: direct users to specific apps based on which geographic location their DNS query originates from.

有关详细信息,请参阅流量管理器路由方法For more information, see Traffic Manager routing methods.

应用服务和流量管理器配置文件App Service and Traffic Manager Profiles

要通过配置来控制应用服务应用流量,则需要在 Azure 流量管理器中创建一个使用前述四种负载均衡方法之一的配置文件,然后将要控制其流量的终结点(在此例中为应用服务)添加到该配置文件。To configure the control of App Service app traffic, you create a profile in Azure Traffic Manager that uses one of the four load balancing methods described previously, and then add the endpoints (in this case, App Service) for which you want to control traffic to the profile. 应用状态(正在运行、已停止或已删除)会定期传送到该配置文件,以便 Azure 流量管理器可以相应地对流量进行定向。Your app status (running, stopped, or deleted) is regularly communicated to the profile so that Azure Traffic Manager can direct traffic accordingly.

在通过 Azure 使用 Azure 流量管理器时,请记住以下几点:When using Azure Traffic Manager with Azure, keep in mind the following points:

  • 对于同一区域内的仅限应用部署,应用服务已经提供了与应用服务模式无关的故障转移和轮循机制功能。For app only deployments within the same region, App Service already provides failover and round-robin functionality without regard to app mode.
  • 对于同一区域中将应用服务与另一 Azure 云服务一起使用的部署,可以组合使用两种类型的终结点以启用混合方案。For deployments in the same region that use App Service in conjunction with another Azure cloud service, you can combine both types of endpoints to enable hybrid scenarios.
  • 在一个配置文件中,只能为每个区域指定一个应用服务终结点。You can only specify one App Service endpoint per region in a profile. 当选择某个应用作为一个区域的终结点后,该区域中的其余应用对于该配置文件会变为不可选择状态。When you select an app as an endpoint for one region, the remaining apps in that region become unavailable for selection for that profile.
  • 在 Azure 流量管理器配置文件中指定的应用服务终结点将出现在配置文件中应用“配置”页面的“域名”部分下,但无法在该位置进行配置。 The App Service endpoints that you specify in an Azure Traffic Manager profile appears under the Domain Names section on the Configure page for the app in the profile, but is not configurable there.
  • 在将应用添加到配置文件后,该应用门户页面的仪表板上的“网站 URL”会显示该应用的自定义域 URL(如果已经设置了一个)。 After you add an app to a profile, the Site URL on the Dashboard of the app's portal page displays the custom domain URL of the app if you have set one up. 否则,它将显示流量管理器配置文件 URL(例如,contoso.trafficmanager.net)。Otherwise, it displays the Traffic Manager profile URL (for example, contoso.trafficmanager.net). 在应用的“配置”页面的“域名”部分下将可以看到应用的直接域名和流量管理器 URL 。Both the direct domain name of the app and the Traffic Manager URL are visible on the app's Configure page under the Domain Names section.
  • 自定义域名将正常工作,但除了将它们添加到应用之外,还必须配置 DNS 映射,使之指向流量管理器 URL。Your custom domain names work as expected, but in addition to adding them to your apps, you must also configure your DNS map to point to the Traffic Manager URL. 有关如何为应用服务设置自定义域的信息,请参阅将现有的自定义 DNS 名称映射到 Azure 应用服务For information on how to set up a custom domain for an App Service app, see Map an existing custom DNS name to Azure App Service.
  • 只能将标准或高级模式下的应用添加到 Azure 流量管理器配置文件。You can only add apps that are in standard or premium mode to an Azure Traffic Manager profile.

后续步骤Next Steps

有关 Azure 流量管理器概念及技术方面的概述,请参阅流量管理器概述For a conceptual and technical overview of Azure Traffic Manager, see Traffic Manager Overview.

有关将流量管理器与应用服务配合使用的详细信息,请参阅博客文章 Using Azure Traffic Manager with Azure Web Sites(将 Azure 流量管理器用于 Azure 网站)和 Azure Traffic Manager can now integrate with Azure Web Sites(Azure 流量管理器现在可以与 Azure 网站集成)。For more information about using Traffic Manager with App Service, see the blog posts Using Azure Traffic Manager with Azure Web Sites and Azure Traffic Manager can now integrate with Azure Web Sites.