Azure Traffic Manager has been around for a while, and is a great way to manage your site across multiple regions. You can route your visitors to a region that will provide the best performance, automatically route them to a secondary region if there is a problem with the primary one or spread the user load evenly across multiple copies of your website hosted in multiple regions.
Recently, Traffic Manager has become available to Azure Web sites, and in this post, I’ll walk you through configuring the two to work together.
Step 1 – Create multiple sites on Azure Web sites
In order to use WATM with Azure Web Sites, you will need to have multiple sites, each in a different region. You can only add one website per region to WATM, so this requirement is important. Another requirement is that the sites are using the Standard service tier.
Step 2 – create Your WATM Profile
WATM will route traffic based on a profile that you create. To create your WATM profile, click on the Traffic Manager node on the left side of the portal:
In the screenshot below, I am creating a new Traffic Manager profile. I have chosen cheshire as my DNS prefix and you can see that my WATM URL will be cheshire.trafficmanager.net.
I’ve selected Performance for my load balancing method. I can change the load balancing after I’ve created my WATM profile in case my needs change after I create the profile. (For details on the different load balancing methods, see Load Balancing Methods later in this blog post.)
Step 3 – Adding Endpoints
Once you’ve created your WATM profile, you’ll want to add your endpoints. You can do that by clicking on the WATM profile and then clicking the Endpoints link at the top of the portal. As you can see in the screenshot below, I’ve selected Web Site as the service type and then checked each of the websites I want included in my WATM profile.
It’s important to note that your endpoints can be a mix of websites and cloud services. Using this method, you can have your application seamlessly transition from Web Sites to a Web Role or vice versa.
Step 4 – Configuring Your WATM Profile
To configure your profile, click the Configure link for your WATM profile in the portal. The configuration allows you to change settings such as the DNS time to live (TTL) and the load balancing method. You can also specify the protocol, port and path that you want the WATM profile to use when monitoring your endpoint for availability.
Final step – testing your site
You now have a WATM profile that points to your sites in Azure web sites. If you browse to the WATM URL (cheshire.trafficmanager.net in my case), you will hit your site, and the specific endpoint you get to depends on the load balancing method that you have configured in your WATM profile.
Azure Web Sites knows how to route the WATM URL to your site because it adds your WATM URL to the custom domains for your site automatically. In the screenshot below, you can see that my WATM URL is listed as a custom domain – this was added automatically when I added the site as an endpoint in my WATM profile:
If you’d like, you can see your WATM profile in action directly by using any tool that does DNS lookup. In my configuration, I have set WATM so that users will be automatically directed to the website with the best performance. Below, I’m using nslookup to see how that works. The client that’s performing this is in the eastern US…notice that the yellow text shows that WATM returned a DNS location of my website located in the East US data center:
If, however, I run this from a client in Southeast Asia, WATM directs me to the site in west Japan, as you can see highlighted below:
This is just the tip of the iceberg. With WATM, you can also configure custom domains and various load balancing methods. To read more about this, visit this blog post. Traffic Manager is a feature that Azure Web Sites customers have been looking forward to for quite some time. I hope this post helps you to take advantage of this powerful new functionality.