What We're Building
In this hands-on exercise, we'll create a high-availability solution for web applications using Azure Traffic Manager. Many organizations face the challenge of keeping their web applications available during regional outages or maintenance. We're going to solve this by deploying web apps across two different Azure regions and setting up automatic failover.
Our Approach
We'll work through four main tasks:
Creating web applications in two Azure regions
Setting up a Traffic Manager profile
Configuring endpoints for failover
Testing our high-availability setup
Task 1: Creating the Web Applications
Let's start by creating our first web application in the East US region.
Open the Azure portal and select "Create a resource," then choose "Web App." If you don't see it immediately, use the search box to find it.
Now we'll configure our first web app with these settings:
Subscription: Your Azure subscription
Resource group: Create new named "Contoso-RG-TM1"
Name: ContosoWebAppEastUS followed by your initials
Publish: Code
Runtime stack: ASP.NET V4.8
Operating system: Windows
Region: East US
Windows Plan: Create new named "ContosoAppServicePlanEastUS"
Pricing Plan: Standard S1
Click the "Monitoring" tab and select "No" for Application Insights to keep things simple for this exercise.
Review your settings and create the web app. Azure will now deploy your first web application.
Now let's create our second web app in West Europe for redundancy. Repeat the same process but with these different settings:
Resource group: Create new named "Contoso-RG-TM2"
Name: ContosoWebAppWestEurope followed by your initials
Region: West Europe
Windows Plan: Create new named "ContosoAppServicePlanWestEurope"
Task 2: Creating the Traffic Manager Profile
Now we'll create the Traffic Manager profile that will handle our traffic routing.
From the Azure portal home, select** "Create a resource"** and search for "Traffic Manager profile."
Click** "Create"** and configure the profile with these settings:
Name: TMProfile followed by your initials
Routing method: Priority
Subscription: Your subscription
Resource group: Contoso-RG-TM1
Resource group location: East US
Review and create the profile. This sets up our traffic management foundation.
To verify both web apps are ready, go to "All services" in the left navigation, select "Web," then "App Services." You should see both web applications listed.
Task 3: Adding Traffic Manager Endpoints
With our Traffic Manager profile ready, we need to connect our web apps as endpoints.
Find your Traffic Manager profile in "All resources" and select it. Under** "Settings,"** choose "Endpoints," then click "Add."
Configure our primary endpoint:
Type: Azure endpoint
**Name: **myPrimaryEndpoint
Target resource type: App Service
Target resource: ContosoWebAppEastUS (East US)
Priority: 1
Click** "Add"** to create the primary endpoint.
Now let's add our failover endpoint using the same process:
**Name: **myFailoverEndpoint
Target resource: ContosoWebAppWestEurope (West Europe)
Priority: 2
The priority setting means traffic will automatically route to our West Europe endpoint if the primary East US endpoint becomes unhealthy.
For better security, let's update the monitoring settings. Go to "Configuration" under Settings, change the protocol to HTTPS and port to 443, then save.
After a few minutes, both endpoints should show "Online" status, indicating they're ready to handle traffic.
Task 4: Testing Our Traffic Manager Setup
Now for the exciting part - testing our high-availability solution!
Go to your Traffic Manager profile overview and copy the DNS name.
Open a new browser tab and paste the DNS name (contoso-tmprofile.trafficmanager.net) into the address bar.
If you see a 404 error, don't worry - this is common with new web apps.
Simply disable and re-enable the profile from the overview page, then refresh.
Currently, all traffic is routing to our primary East US endpoint because we set it to priority 1.
Now let's test our failover capability. We'll simulate an outage by disabling the primary endpoint.
On the Traffic Manager overview, click the number "2" next to Endpoints.
Find myPrimaryEndpoint and click the edit (pencil) icon.
Uncheck "Enable Endpoint" and save.
The primary endpoint should now show as disabled.
Open a new browser session and navigate to your Traffic Manager DNS name again. You should still see your web application working, but now it's being served from the West Europe endpoint!
Cleaning Up
When you're finished testing, remember to clean up your resources to avoid ongoing charges.
Open Cloud Shell in the Azure portal and run:
text
Remove-AzResourceGroup -Name 'Contoso-RG-TM1' -Force -AsJob
Remove-AzResourceGroup -Name 'Contoso-RG-TM2' -Force -AsJob
What We Learned
Through this exercise, we've built a robust high-availability solution that can automatically handle regional outages. The key takeaways are:
Azure Traffic Manager provides DNS-level load balancing across global regions
Priority routing ensures traffic goes to your preferred endpoints first
Automatic health monitoring and failover keep your applications available
Geographic redundancy protects against regional disruptions
This solution is particularly valuable for e-commerce sites, business applications, and any service where downtime means lost revenue or productivity.
Next Steps
If you want to explore further, consider:
Trying different routing methods like weighted or geographic routing
Adding custom domains and SSL certificates
Setting up monitoring and alerts for your endpoints
Implementing nested Traffic Manager profiles for complex scenarios
Remember, the best disaster recovery plan is one you've tested thoroughly - and now you have the skills to build and test these solutions in Azure.
Top comments (0)