Introduction - Azure Traffic Manager
A DNS-based traffic load balancer is Azure Traffic Manager. This service lets you disperse traffic to your public-facing applications among Azure regions across the world. For specific cases, Azure offers a set of fully managed load-balancing options.
Azure Traffic Manager Routing Methods
Priority
When you choose priority routing, a prioritized list of service endpoints appears, with the primary service endpoint receiving the highest priority for all traffic. If the primary service endpoint is down, traffic is routed to the next highest priority endpoint, and so on.
Weighted
When you want to distribute traffic uniformly or utilize pre-defined weights across a collection of endpoints, you use the weighted routing approach. In this traffic-routing approach, you assign a weight to each endpoint in the Microsoft Azure Traffic Manager profile configuration, which is an integer ranging from 1 to 1000.
Performance
When you wish to improve the responsiveness of several apps by routing traffic to the place nearest to the user, this traffic routing strategy is utilized. The 'closest' endpoint isn't always the one with the shortest geographic distance. Instead, the 'Performance' traffic-routing mechanism uses network latency to select the closest endpoint.
Geographic
Each endpoint linked with a profile must have a set of geographic regions allocated to it in geographic routing. When a region or a group of regions is assigned to an endpoint, all requests from that region or set of regions are routed exclusively to that endpoint.
Multivalue
For Azure Traffic Manager profiles with only IPv4/IPv6 addresses as endpoints, you can choose MultiValue. All healthy endpoints are returned when a question for this profile is received.
Subnet
To map sets of end-user IP address ranges to a specific endpoint within an Azure Traffic Manager profile, utilize the Subnet traffic-routing mechanism. When a request is received, the endpoint that is returned is the one that is mapped to the source IP address of the request.
In this scenario, I'll present two virtual machines that have been connected into Azure Traffic Manager and are prioritized.
I have already created a Resource Group Named Az_TM_RG
Now I’m going to create a Virtual Network
Step 1
Search Virtual Networks and Create Virtual Network
Keeping Default for IP Address Space and Subnet
Review + Create
Step 2
Now I’m going to create two Virtual Machines and installing IIS Role
Virtual Machine 1
Select the Virtual Network and Keep the Subnet Default
Review + Create
Create the Second VM also as above Configuration
Step 3
Now I’m going to Automate the IIS Install on Both Azure Virtual Machines
Run below Query in Cloud Shell
Change the Highlighted Resource Group name, VM name, and Location as your Configuration.
Set-AzVMExtension -ResourceGroupName "Az_TM_RG" -ExtensionName "IIS" -VMName "TM-VM1" -Location "EastUS" -Publisher Microsoft.Compute -ExtensionType CustomScriptExtension -TypeHandlerVersion 1.8 -SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}'
This will take 5 to 7 minutes and change the highlighted values to Second Virtual Machine and Run again the modified script to install IIS Role in second VM.
Copy the Virtual Machine public IP and browse on your browser then you can see the VM Name as below, (Check with your second VM also)
Step 4
Before creating the Azure Traffic Manager profile, we need to configure DNS Name for both Virtual Machines,
Navigate to Virtual Machines, DNS name Click Not Configured.
Select the DNS name
Save.
Repeat the above scenario for second Virtual Machine also.
Step 5
Now we will create an Azure Traffic Manage Profile,
Search Traffic Manager
Create Traffic Manager Profile
As I described above routing methods, now you can select the required routing method as your requirement and in this scenario, I’m going to use Priority Based routing Method.
Create.
It will take up to 5min and check by Refresh.
Click the Created Traffic Manager Profile and Navigate to Configuration and you can see the Endpoint Monitoring Options.
Now Navigate to Settings Tab – Endpoints and Create
Now you can see the Endpoint Types as below,
Azure Endpoint
Use this type to load-balance traffic to a cloud service, webapp or public IP Address in the same subscription.
External Endpoint
Use this type to load-balancer traffic to any fully-qualified domain name (FQDN), even for applications not hosted in Azure like you can use OnPrem
.
In this scenario, I’m selecting Azure Endpoint since I’m going to use created two Azure virtual Machines and as Target Resource, I’m selecting Public IP Address
Click Add.
Click Add again to Add second Virtual Machines as Endpoint and Repeat the above scenario and select the priority as priority 2.
I have selected Priority 1 as the TM-VM1 and as Priority 2 TM-VM2.
After few minutes Monitor Status will change Checking Endpoint to Online.
Now navigate to the Overview page and copy the DNS Name and paste in the browser, then you will get the Priority 1 Virtual Machine Name.
Step 6
Now Turn off the TM-VM1 Virtual Machines and will see the Traffic is navigated to Priority 2 Virtual Machine.
Go to Virtual Machines – Select Virtual Machines 1 (TM-VM1) and Click Stop. (If you need you can reserve the public IP Address for that Virtual Machine)
Now Navigate to Traffic Manager Profiles,
Click the Profiles and Navigate to Overview Page and Refresh the Page,
You will be able to see the Virtual Machines 1 Endpoint (ArticleEP) Monitor status is Degraded as it’s not online.
Now copy the DNS Name and Browse and you will get the second Virtual Machine name (TM-VM2)
Summary
We learned the Overview of Azure Traffic Manager and all routing Methods and learned how to deploy and Configuring Priority Based Endpoints Step by Step. Please leave a comment in the comment box if you have any questions.