Learn how to configure traffic manager to route between different WebApps and how it's beneficial to use the Azure traffic manager.
- [Narrator] In previous Azure courses we've talked quite a bit about the traffic manager, but more as how it applies to your virtual machines. But we can also use the Azure traffic manager to route traffic between our apps. Using the Azure traffic manager ensures our apps are highly responsive, and highly available. We can select from one of three load balancing methods when we configure the traffic manager. First we have the priority method. When we use this method all traffic is directed to a specific end point but a backup endpoint is available if the primary fails.
We have the weighted method, which distributes traffic among apps equally, or we can distribute it based on a weight that we define, and finally there's the performance method. In this method, traffic is directed to the app that is closest to the client, and I don't necessarily mean closest as in physical geography, but as in closest as the shortest return time back to the client. Before configuring our traffic manager for our apps there's a couple points to remember. First of all, your web apps that are in the same data center will automatically be load balanced for you.
You don't have to worry about traffic manager and load balancing. Web apps spread across multiple data centers will need to be load balanced, and that is what I'll show you in the demo, and finally all of your end points must be in the same subscription in order to provide load balancing between the apps. Let's take a look at how traffic manager works. First of all we have our user. Our user requests an FQDN, or fully qualified domain name, and the request is forwarded to the traffic manager using the C name record.
Keep in mind if you're using your own custom domain name you must configure your DNS records. The request is then sent to traffic manager, which monitors the end points, and return the IP of the end point that is to be used by the client. And finally, the client connects directly to that end point. You'll notice the client does not go through the traffic manager to access the app, but they connect directly to the app via the end point. Let's go ahead and take a look at setting up traffic manager in Azure.
As you can see, we have logged into Azure. We are currently in the scaling and resilience resource group and I have three app services up and running. We have the prod east coast web app, and the prod west coat web app. Those are the two that we're going to load balance. Each of these apps is set up in a separate data center, hence the naming for east and west. The first thing I'm going to do is add in the Azure traffic manager. To do so I'm going to click add.
I'm going to search for the traffic manager. I'm going to select traffic manager profile. The traffic manager profile blade is then presented to us. It provides a little bit of a blurb about the traffic manager and what it can do for us. I'm going to go ahead and click create. We must provide a unique name for our traffic manager.
I'm naming my traffic manager profile prod web app TM, TM being short for traffic manager. I'm going to select the performance method for routing. My subscription is already chosen for me, as is the resource group. Again, I could modify these are required. Click create. It'll take a moment for the traffic manager to be created. We can see our deployment succeeded. I'm going to go ahead and close the traffic manager profile blade, and then the everything blade, and I'm going to refresh on the resource group.
You'll notice that we now have the prod web app TM, and we're going to go ahead and configure the end points. I'm going to click on end points under settings. I'm going to go ahead and add our end points. We need to do both the east and west coast end points. We'll be choosing Azure end points as both of our services are internal, and we'll start off with the east coast.
Provide a descriptive name, and then our service. In our case we'll be selecting the app service. Now we select our target. And this is our east coast. So we'll do prod east coast web app, and then select OK. Next we'll repeat the same process for the second end point.
Again, this will be an app service. You could also choose an app service slot, and this is referring to the staging slots, or deployment slots we talked about in chapter one. If you're going to add one of these it must be the production slot that you're selecting. I'm going to select the west coast, and click OK. It will take a moment for everything to configure.
If you find that you're stuck on checking end point, refreshing the screen may help. There we go. So we can see both of these are now online. Fantastic. Keep in mind that if you need to do any web maintenance you'll want to disable the end point. And finally, let's go ahead and verify that our traffic manager is performing as we have set it up to by launching command prompt and we're going to run that in administrative mode.
To do so, all I'm going to do is use the Windows key, start typing command, right click on command prompt, run as administrator, and I'm going to use good old NS look up. I am entering the name of our traffic manager which happens to be prod web app TM.traffic manager.net. As you'll recall, we set this up in performance mode, meaning it should return the app in the location that is closest to me, and by closest, again, I do not mean physically closest, but has the shortest return time.
I happen to be in Toronto, Ontario. So in all likelihood, my end point should be the east US. And it is. And we can see that here. So we can see that our NS look up brought up our prod app.TM.traffic manager .net, where our closest end point will be at the prod east coast web app.Azure websites.net. Setting up the Azure traffic manager ensures that your traffic is directed to the appropriate apps and end points as required.
- Deploying Web Apps
- Creating App Service plans
- Deploying and moving apps
- Configuring app settings
- Managing Web Apps using PowerShell and CLI
- Configuring alerts
- Enabling diagnostic logs
- Retrieving and streaming logs
- Configuring Web Apps for scale and resilience