Azure – Networking – Part 19 – Azure Traffic Manager 2 -Create Traffic Manager Profile using (Cloud Shell) PowerShell
In our last article, we have discussed about the basics of Azure Traffic Manager. Today in this article we will continue our journey with Azure Traffic Manager and create Traffic Manager Profile using PowerShell.
Tool Installation Articles :
- Configure Azure Command Line Interface ( Azure CLI) On Windows
- Configure PowerShell For Microsoft Azure Az Module On Windows
Previous Azure Series :
- Learn Basics Of Azure Networking In 100 Hours
- Learn Basics Of Microsoft Azure Storage services
- Learn Basic Of Azure Active Directory And Azure Identity And Access Management
- Azure DevOps – Learn at one place
- Learn Basics Of Lift-And-Shift Migration To Azure
If you have missed our previous articles on azure networking, please check it in following links.
Next Article : Azure – Networking – Part 20 – Azure Route Table
Use Case Of Azure Traffic Manager :
Without taking much of your time, I am starting with create a new Azure Traffic Manager Profile using PowerShell. Initially my plan was to take a little complex use case for our hands-on but due to some technical issue, I am not able to connect to any of my VM. So in last moment decided, to take a very simple use case for our hands-on. Here we will configure two App service as endpoints for Traffic Manager and one will be the Primary and the other one as secondary/failover end-point. We will see how Traffic Manager redirect traffics to the failover/secondary end-point if the primary end-point is not available.
How To Use PowerShell In Azure :
Azure hosts, Azure Cloud Shell, an interactive shell environment that we can use through our browser. We can use either Bash or PowerShell with Cloud Shell to work with Azure services. In this case we don’t have to install PowerShell module locally.
If we want to install and use PowerShell locally, we need to install Azure PowerShell module on our machine. For guidance see Install Azure PowerShell module. I am going to use browser based cloud shell. There are following two ways to open the command prompt in browser
1. Select the Cloud Shell button on the top-right menu bar in the Azure portal.
2. Lunch Cloud Shell from browser by opening http://shell.azure.com as shown in the following figure.
Configure Traffic Manager Profile :
So far so good. If we are ready with our command prompt, let’s start with our hands-on 🙂 and follow the steps.
Step 1 : Create new Traffic Manager Profile
As shown in the following figure create a new Traffic Manager Profile.
Step 2 : Create two new App Service Plan for both end point
In next step, lets create two Azure App Service Plan using New-AzAppServicePlan in different location as shown in the following figure. This command creates two App Service plan name started from “Manas_AppServicePlan” in the resource group named “KJ_TrafficManagerRG” in Geo location West Europe and East US.
Step 3 : Create two new Web App in New App Service Plans
After creating the App service plan , let’s create two App Service under both App service plan using New-AzWebApp, as shown in the following figures. later we will configure those web app as end points of the traffic manager profile. After creating two web app, using KUDO tool , I have modified it’s default landing page, so that we can understand, which web app is responding our requests.
Step 4 : Configure Traffic Manager Profile Endpoints
Add the two App services as Traffic Manager endpoints using New-AzTrafficManagerEndpoint to the Traffic Manager profile as shown in the following figures.
Testing Azure Traffic Manager :
We have done with all of our configuration and now time comes for testing.
Step 1 : Collect Traffic Manager Full DNS Name
Using Get-AzTrafficManagerProfile we can get RelativeDnsName value as shown in the below figure.
Once we got RelativeDnsName value, let’s construct the full DNS name by post-fixing ” .trafficmanager.net ” to it. In our case the RelativeDnsName is “kj-trafficmanagerprofile” and the full DNS name would be http://kj-trafficmanagerprofile.trafficmanager.net. We can also get the DNS full name from portal in overview section as shown in the following figure.
Step 2 : Browse full DNS name in browser
In a web browser, let’s browse our DNS name, in our case the URL will be http://kj-trafficmanagerprofile.trafficmanager.net and we received the result as shown in the following figure.
we can see all the traffics redirected to “MAnas_App1-WestEurope ” End Point by traffic manager because the priority of this end point set to 1, as shown in the following figure.
Step 3: Disable Primary End Point
We have seen that, traffic manager is redirecting all traffics based on the priority of the end-point. As per the priority, in this scenario it redirecting all traffic to “MAnas_App1-WestEurope “. To test, if the failover end-point working or not, let’s disable “MAnas_App1-WestEurope ” end-point as shown in the following figure and see what is happening when we browse traffic manager DNS name ( http://kj-trafficmanagerprofile.trafficmanager.net/ ).
After disabling the primary end-point, let’s browse traffic manager DNS name ( http://kj-trafficmanagerprofile.trafficmanager.net/ ). Now we can see the traffic is still served and the web app is still available. This time traffic manager redirect all traffics to failover/secondary end-point (Manas-App2-EastUS) as we can see in the following figure.
Release Resources :
After we have done with our hands-on, let’s clean up resources using using Remove-AzResourceGroup.
Hope this article helps you with your hands on. we can download the complete script here. In next article I will come up with a new Azure networking concept so thanks for reading 🙂 and my next article is Azure – Networking – Part 20 – Azure Route Table.
Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more.
If you have any suggestion / feedback / doubt, you are most welcome. Stay tuned on Knowledge-Junction, will come up with more such articles.
Thanks for reading 🙂 .