At TechEd North America, we announced Azure Traffic Manager support for endpoints external to Azure. We are happy to announce a further enhancement, adding support for weights when using round-robin load-balancing. Together, these features enable a range of new scenarios, including distributing traffic in hybrid scenarios between on-premises and the cloud.
These features are supported now through our PowerShell cmdlets—which are also newly extended to support Traffic Manager.
Introduction
Traffic Manager allows you to load balance incoming traffic across multiple services whether they’re running in the same datacenter or across different datacenters around the world. Key scenarios enabled by Traffic Manager include improving application performance by routing end users to the closest deployment, and enabling high availability by monitoring your services and providing automatic failover when a service goes down.
Up until recently, only Azure Cloud Services (both IaaS and PaaS) and Azure Websites were supported. We’ve now enabled Traffic Manager support for endpoints external to Azure. We’ve also enhanced the round-robin load-balancing method to support weights, giving more control over how traffic is distributed between endpoints.
These enhancements bring the benefits of Traffic Manager to a wider range of applications and enable a number of new scenarios.
For example, external endpoint support means Traffic Manager now enables you to use Azure to extend an existing on-premises or externally-hosted deployment. This could be for additional geo-locations for improved performance, increased redundancy either as active-active or failover, or additional capacity either continuously or as a ‘burst to cloud’ to handle a spike in demand. External endpoints also allow a Traffic Manager profile to span services in separate Azure subscriptions, something that wasn’t previously possible.
Weighted round-robin enables additional new scenarios, such as tailoring the load across deployments to maximize utilization, or diverting a small percentage of traffic to a separate deployment as part of an ‘A/B testing’ scheme. Used together with external endpoints it can enable a smooth migration of an on-premises application to the cloud—start with 100% of the traffic directed to the on-premises application, then ‘turn the dial’ to gradually migrate traffic to the cloud-based version.
These features are currently available via our REST API and our new Traffic Manager PowerShell cmdlets. They are not available via the Azure management portal. The remainder of this blog post will show you how to use the new PowerShell support for Traffic Manager to leverage these new features.
Getting Started
To get started with the Azure PowerShell, see How to Install and Configure Azure PowerShell. Please note that you’ll need to use version 0.8.3 or higher.
Viewing Existing Profiles and Endpoints
The ‘Get-AzureTrafficManagerProfile’ cmdlet retrieves an array of Profile objects, which you can then view:
PS C:> $profiles = Get-AzureTrafficManagerProfile PS C:> $profiles | Format-Table Name DomainName Status ---- ---------- ------ MyProfile myprofile.trafficmanage... Enabled websites websites.trafficmanager... Enabled
Alternatively, by specifying the ‘-Name’ parameter, you can retrieve just a single Profile. Each Profile contains fields for the profile name, Traffic Manager domain, TTL and endpoint monitoring settings:
PS C:> $profile = Get-AzureTrafficManagerProfile -Name "MyProfile" PS C:> $profile | Format-List TimeToLiveInSeconds : 30 MonitorRelativePath : / MonitorPort : 80 MonitorProtocol : Http LoadBalancingMethod : RoundRobin Endpoints : {tm-demo-us.cloudapp.net, www.microsoft.com} MonitorStatus : CheckingEndpoints Name : MyProfile DomainName : myprofile.trafficmanager.net Status : Enabled
There is also an array of Endpoints, which in turn contain the endpoint domain name, location, type, status, monitoring status, and weight:
PS C:> $profile.Endpoints | Format- DomainName Location Type Status MonitorStatus Weight ---------- -------- ---- ------ ------------- ------ tm-demo-us... CloudService Enabled Online 1 www.micros... Any Enabled Online 1
Creating a Profile and Adding Endpoints
The general pattern is that you use a ‘Profile’ object to represent your Traffic Manager profile. You configure this Profile offline, using the cmdlets, then when it’s ready you load it into Azure using the ‘Set-AzureTrafficManagerProfile’ cmdlet. (Remember, the only cmdlets that actually call the Azure management API are ‘New-AzureTrafficManagerProfile’ and ‘Set-AzureTrafficManagerProfile’.)
The following example creates a new Traffic Manager Profile, adds two endpoints to it, and submits the result to Azure:
PS C:> $profile = New-AzureTrafficManagerProfile -Name "MyProfile" -DomainName "myprofile.trafficmanager.net" -LoadBalancingMethod "RoundRobin" -Ttl 30 -MonitorProtocol "Http" -MonitorPort 80 -MonitorRelativePath "/" PS C:> $profile = Add-AzureTrafficManagerEndpoint -TrafficManagerProfile $profile -DomainName "myapp-eu.cloudapp.net" -Status "Enabled" -Type "CloudService" PS C:> $profile = Add-AzureTrafficManagerEndpoint -TrafficManagerProfile $profile -DomainName "myapp-us.cloudapp.net" -Status "Enabled" -Type "CloudService" PS C:> Set-AzureTrafficManagerProfile –TrafficManagerProfile $profile
These commands (as with the other examples later in this blog) can also be ‘piped’:
PS C:> New-AzureTrafficManagerProfile -Name "MyProfile" -DomainName "myprofile.trafficmanager.net" -LoadBalancingMethod "RoundRobin" -Ttl 30 -MonitorProtocol "Http" -MonitorPort 80 -MonitorRelativePath "/" | Add-AzureTrafficManagerEndpoint -DomainName "myapp-eu.cloudapp.net" -Status "Enabled" -Type "CloudService" | Add-AzureTrafficManagerEndpoint -DomainName "myapp-us.cloudapp.net" -Status "Enabled" -Type "CloudService" | Set-AzureTrafficManagerProfile
External Endpoints
The Add-AzureTrafficManagerEndpoint cmdlet can be used to create an external endpoint (i.e. an endpoint outside of Azure). Simply specify the domain name for the endpoint in the DomainName parameter and specify the Type as “Any”:
PS C:> Add-AzureTrafficManagerEndpoint -TrafficManagerProfile $profile -DomainName "www.microsoft.com" -Status "Enabled" -Type "Any" | Set-AzureTrafficManagerProfile
When using external endpoints together with Performance load-balancing, an additional ‘Location’ parameter is needed. This tells Azure the location of your external endpoint, so Traffic Manager can geo-route traffic appropriately.
PS C:> Add-AzureTrafficManagerEndpoint -TrafficManagerProfile $profile -DomainName "www.microsoft.com" -Status "Enabled" -Type "Any" -Location "North Europe" | Set-AzureTrafficManagerProfile
The available locations reflect Azure’s global network of data centers, which can be found using the Get-AzureLocation cmdlet:
PS C:> $loc = Get-AzureLocation PS C:> $loc.Name | Format-List East Asia Southeast Asia North Europe West Europe East US West US Japan East Japan West Brazil South North Central US South Central US
If you change the load-balancing method, e.g. to Round Robin, and then switch back to Performance, Traffic Manager remembers (but ignores) your previously configured endpoint locations, so you don’t need to specify them again.
Weighted Endpoints
Weighting only applies to Traffic Manager policies using the ‘Round Robin’ load-balancing method. It’s available for all endpoint types. Traffic is distributed proportionately to the weights of all currently active, healthy endpoints.
You can specify any weight from 1 to 1,000 using the ‘Weight’ parameter as shown in the example below. It’s an optional parameter—by default, all endpoints have a weight of ‘1’.
PS C:> Add-AzureTrafficManagerEndpoint -TrafficManagerProfile $profile -DomainName "tm-demo-us.cloudapp.net" -Status "Enabled" -Type "CloudService" -Weight 70 | Set-AzureTrafficManagerProfile
Similarly to external endpoint locations, weights are remembered (but ignored) if you change load-balancing method e.g. to Performance and then switch back to Round Robin.
Traffic Manager works at the DNS level, and DNS is by design cached both by DNS clients and by local DNS resolvers run by organizations and ISPs. Weighted traffic distributions work best for conventional Internet-facing applications, where there is a large number of clients—in these cases, DNS caching doesn’t affect the distribution of traffic. However, where a small number of clients is used, or all clients sit behind a small number of local DNS servers, caching may skew the traffic distributions. In these cases, traffic should be distributed on a per-connection basis, for example by using application-level HTTP 302 re-directs.
Other Common Operations
Examples of other common operations for Traffic Manager profiles are given below.
Enabling and Disabling Endpoints
You can disable an endpoint, and thus bring it out of rotation. This stops Traffic Manager billing for this endpoint, but keeps it in your profile so it can easily be re-enabled.
PS C:> $profile = Get-AzureTrafficManagerProfile -Name "MyProfile" PS C:> $profile.Endpoints[0].Status = "Disabled" PS C:> Set-AzureTrafficManagerProfile –TrafficManagerProfile $profile
Re-Ordering Endpoints
Endpoint order determines the failover sequence when using ‘Failover’ load-balancing method. This example shows how to re-sequence a pair of endpoints:
PS C:> $profile = Get-AzureTrafficManagerProfile -Name "MyProfile" PS C:> $profile.Endpoints[0],$profile.Endpoints[1] = $profile.Endpoints[1],$profile.Endpoints[0] PS C:> Set-AzureTrafficManagerProfile –TrafficManagerProfile $profile
Deleting an Endpoint
To delete an endpoint, use the ‘Remove-AzureTrafficManagerEndpoint’ cmdlet:
PS C:> $profile = Get-AzureTrafficManagerProfile -Name "MyProfile" PS C:> Remove-AzureTrafficManagerEndpoint -TrafficManagerProfile $profile -DomainName www.microsoft.com PS C:> Set-AzureTrafficManagerProfile –TrafficManagerProfile $profile
Updating Endpoint Monitoring Settings
In this example, we’ll modify the monitoring path to point to a dedicated monitoring page:
PS C:> $profile = Get-AzureTrafficManagerProfile -Name "MyProfile" PS C:> $profile.MonitorRelativePath = "/monitor.aspx" PS C:> Set-AzureTrafficManagerProfile –TrafficManagerProfile $profile
Disabling a Profile
You can disable a Traffic Manager profile entirely. This stop all traffic to all endpoints, and also stops billing for this profile. This is done using dedicated cmdlets:
PS C:> Disable-AzureTrafficManagerProfile -Name "MyProfile" PS C:> Enable-AzureTrafficManagerProfile -Name "MyProfile"
Deleting a Profile
Finally, you can also delete a Traffic Manager profile altogether (the ‘Force’ flag over-rides the confirmation prompt):
PS C:> Remove-AzureTrafficManagerProfile -Name "MyProfile" -Force
FAQ
Can I use External Endpoints or Weights via the Azure Management Portal?
These features can currently only be configured via our REST API and PowerShell cmdlets. They are not available via the Azure management portal.
However, you can continue to use the Azure management portal to view the status of profiles using External Endpoints or Weights, and even to manage other settings on those profiles, such as enabling and disabling endpoints or configuring monitoring settings.
Can I mix both Azure endpoints (Cloud Services and Websites) with External Endpoints in the same Traffic Manager profile?
Yes. There are no restrictions on how you combine endpoints of different types within a profile.
Are there any changes to the billing model for External Endpoints and Weights?
External Endpoints are billed at a higher rate than Azure-based endpoints. There is no charge for using Weights. For full details, see our pricing page.
Is Azure Traffic Manager supported in the Azure SDKs or Xplat-CLI?
A Traffic Manager management library is included in the .NET SDK. It is not yet supported in the Java SDK or Node.js SDK, nor the Xplat-CLI.
Can I set up Azure services as External Endpoints?
Yes, you can use External Endpoints to reference other Azure services (excluding Websites). These will be billed at the same rate as other Azure-based endpoints. However, unlike Cloud Services and Websites, if you disable the underlying service you will continue to be billed for the corresponding Traffic Manager endpoint, until you disable or delete the endpoint in Traffic Manager explicitly.
Where can I get more information on Azure Traffic Manager?
The Azure portal contains an overview of the Traffic Manager service and scenarios. It also contains pricing and SLA details.
MSDN contains a more detailed overview, including descriptions of Traffic Manager’s load-balancing methods and endpoint monitoring and configuration.
In addition to Azure’s paid-for support plans, our MSDN forum can be used to ask questions on any aspect of Azure relating to DNS or Traffic Manager. Feature suggestions should be posted to our feedback site, where you can also vote for existing suggestions.