Reader small image

You're reading from  Azure Networking Cookbook, Second Edition - Second Edition

Product typeBook
Published inDec 2020
PublisherPackt
ISBN-139781800563759
Edition2nd Edition
Tools
Concepts
Right arrow
Author (1)
Mustafa Toroman
Mustafa Toroman
author image
Mustafa Toroman

Mustafa Toroman is a solution architect focused on cloud-native applications and migrating existing systems to the cloud. He is very interested in DevOps processes and cybersecurity, and he is also an Infrastructure as Code enthusiast and DevOps InstituteAmbassador. Mustafa often speaks at international conferences about cloud technologies. He has been an MVP for Microsoft Azure since 2016 and a C# Corner MVP since 2020. Mustafa has also authored several books about Microsoft Azure and cloud computing, all published by Packt.
Read more about Mustafa Toroman

Right arrow

11. Traffic Manager

Azure Load Balancer is limited to providing high availability and scalability only to Azure virtual machines (VMs). Also, a single load balancer is limited to VMs in a single Azure region. If we want to provide high availability and scalability to other Azure services that are globally distributed, we must introduce a new component—Azure Traffic Manager. Azure Traffic Manager is DNS-based and provides the ability to distribute traffic over services and spread traffic across Azure regions. But Traffic Manager is not limited to Azure services only; we can add external endpoints as well.

We will cover the following recipes in this chapter:

  • Creating a new Traffic Manager profile
  • Adding an endpoint
  • Configuring distributed traffic
  • Configuring traffic based on priority
  • Configuring traffic based on geographical location
  • Managing endpoints
  • Managing profiles
  • Configuring Traffic Manager with load balancers

Technical requirements

For this chapter, an Azure subscription is required.

The code samples can be found at https://github.com/PacktPublishing/Azure-Networking-Cookbook-Second-Edition/tree/master/Chapter11.

Creating a new Traffic Manager profile

Traffic Manager provides load balancing to services, but traffic is routed and directed using DNS entries. The front end is a Fully Qualified Domain Name (FQDN) assigned during creation, and all traffic coming to Traffic Manager is distributed to endpoints in the backend. In this recipe, we'll create a new Traffic Manager profile.

Getting ready

Before you start, open your browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to create a new Traffic Manager profile, we must do the following:

  1. In the Azure portal, select Create a resource and choose Traffic Manager Profile under the Networking services (or search for Traffic Manager Profile in the search bar).
  2. In the new pane, we must provide information for the Name, Routing method, Subscription, and Resource group fields:
    Creating Traffic Manager profile by providing various information

    Figure 11.1: Providing information for a new Traffic Manager profile

  3. Note that under the routing methods...

Adding an endpoint

After a Traffic Manager profile is created, we have the frontend endpoint and routing method defined. But we still need to define where the traffic needs to go after it's reached Traffic Manager. We need to add endpoints to the backend and define where the traffic is directed. In this recipe, we'll add a new endpoint to Traffic Manager.

Getting ready

Before we can add endpoints to Traffic Manager, we need to create them. Executing the following script in PowerShell can help you create two web apps quickly:

$ResourceGroupName = "packt-demo-webapp"
$webappname="packt-demo-webapp"
$location1="West Europe"
$NumberOfWebApps= 2
New-AzResourceGroup -Name $ResourceGroupName '
-Location $location
$i=1
Do
{
New-AzWebApp -Name $webappname'-0'$i '
-Location $location '
-AppServicePlan $webappname '
-ResourceGroupName $ResourceGroupName
} While (($i=$I+1) -le $NumberOfWebApps) 

The script can be...

Configuring distributed traffic

The default routing method for Traffic Manager is performance. The performance method will distribute traffic based on the best possible performance available. This method only takes full effect if we have multiple instances of a service in multiple regions. As this often isn't the case, other methods are available, such as distributed traffic (also referred to as the weighted routing method). In this recipe, we'll configure Traffic Manager to work in distributed mode.

Getting ready

Before you start, open the browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to set distributed traffic, we must do the following:

  1. In the Azure portal, locate the previously created Traffic Manager profile.
  2. Under Settings, select the Configuration option. Here, we have multiple options that we can change, such as DNS time to live (TTL), protocols, and failover settings:
    Setting the distributed traffic in the configuration pane

    Figure 11.7: The Configuration...

Configuring traffic based on priority

Another routing method available is priority. Priority, as its name suggests, gives priority to some endpoints, while some endpoints are kept as backups. Backup endpoints are only used if endpoints with priority become unavailable. In this recipe, we'll configure Traffic Manager to route traffic based on priority.

Getting ready

Before you start, open your browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to set the routing method to Priority, we must do the following:

  1. In the Azure portal, locate the previously created Traffic Manager profile.
  2. Under Settings, select the Configuration option.
  3. Change Routing method to Priority, as shown in Figure 11.9:
    Setting the routing method to Priority in the Configuration pane

Figure 11.9: Changing the routing method to Priority

How it works…

Priority sets a priority order for endpoints. All traffic will first go to the endpoints with the highest priority. Other endpoints (with...

Configuring traffic based on geographical location

Geographical location is another routing method in Traffic Manager. This method is based on network latency and directs a request based on the geographical location of the origin and the endpoint. When a request comes to Traffic Manager, based on the origin of the request, it's routed to the nearest endpoint in terms of region. This way, it provides the least network latency possible. In this recipe, we'll configure Traffic Manager to route traffic based on geographical location.

Getting ready

Before you start, open the browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to set the routing method to be based on geographical location, we must do the following:

  1. In the Azure portal, locate the previously created Traffic Manager profile.
  2. Under Settings, select the Configuration option.
  3. Change the routing method to Geographic, as shown in Figure 11.10:
    Setting the routing method to Geographic in the Configuration pane
...

Managing endpoints

After we add endpoints to Traffic Manager, we may have to make changes over time. This can be either to make adjustments or to completely remove endpoints. In this recipe, we'll edit existing Traffic Manager endpoints.

Getting ready

Before you start, open the browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to make changes to endpoints in Traffic Manager, we must do the following:

  1. In the Azure portal, locate the previously created Traffic Manager.
  2. Under Settings, select Endpoints. From the list that appears, select the endpoint you want to change:
    Selecting the endpoints to make changes to them

    Figure 11.11: Changing endpoints in Traffic Manager

  3. In the new pane, we can either delete, disable, or make adjustments to the endpoint:
    Making changes to the endpoints by editing various options

Figure 11.12: Pane for making adjustments to the endpoint

How it works…

The existing endpoint in the Traffic Manager backend can be changed. We can delete the endpoint to completely remove...

Managing profiles

The Traffic Manager profile is another setting that we can manage and adjust. Although it has very limited options, where we can only disable and enable Traffic Manager, managing the profile setting can be very useful for maintenance purposes. In this recipe, we'll manage our Traffic Manager profile.

Getting ready

Before you start, open your browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to make changes to the Traffic Manager profile, we must do the following:

  1. In the Azure portal, locate the previously created Traffic Manager profile.
  2. In Overview, select the Disable profile option and confirm by clicking on the Yes button:
    Disabling the Traffic Manager profile by clicking on the Yes button

    Figure 11.13: Disabling a profile

  3. Once the profile has been disabled, it can be enabled again with the Enable profile option:
    Enabling the Traffic Manager profile by clicking on the Enable profile option

Figure 11.14: Enabling a profile

How it works…

Managing the Traffic Manager profile with the disable and enable options...

Configuring Traffic Manager with load balancers

Combining Traffic Manager with load balancers is often done to provide maximum availability. Load balancers are limited to providing high availability to a set of resources located in the same region. This gives us an advantage if a single resource fails, as we have multiple instances of a resource. But what if a complete region fails? Load balancers can't handle resources in multiple regions, but we can combine load balancers with Traffic Manager to provide even better availability with resources across Azure regions. In this recipe, we'll configure Traffic Manager to work with load balancers.

Getting ready

Before you start, open your browser and go to the Azure portal via https://portal.azure.com.

How to do it…

In order to set up Traffic Manager with a load balancer, we must do the following:

  1. In the Azure portal, locate the load balancer and verify that it has the assigned IP address as covered...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Azure Networking Cookbook, Second Edition - Second Edition
Published in: Dec 2020Publisher: PacktISBN-13: 9781800563759
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Mustafa Toroman

Mustafa Toroman is a solution architect focused on cloud-native applications and migrating existing systems to the cloud. He is very interested in DevOps processes and cybersecurity, and he is also an Infrastructure as Code enthusiast and DevOps InstituteAmbassador. Mustafa often speaks at international conferences about cloud technologies. He has been an MVP for Microsoft Azure since 2016 and a C# Corner MVP since 2020. Mustafa has also authored several books about Microsoft Azure and cloud computing, all published by Packt.
Read more about Mustafa Toroman