Ensuring High Availability for Web Applications using Azure App Service and Azure Traffic Manager
Published Sep 08 2023 12:00 PM 3,224 Views
Brass Contributor

The Challenge: High Availability Matters:

As student entrepreneurs, we understand that ensuring high availability for our web applications isn't just a convenience; it's a necessity. Downtime and unreliable performance can impact our startups and student projects significantly. It's not just about keeping users happy; it's about seizing opportunities and maintaining our reputation in a competitive landscape. Picture this: You're preparing for a crucial presentation while simultaneously managing your web app, and suddenly it goes offline. That downtime can cost more than just frustration; it can cost opportunities. In the dynamic world of startups and academia, high availability isn't a luxury; it's a lifeline 

The Solution: Azure App Service and Azure Traffic Manager 

Azure offers a robust set of tools for building and deploying highly available applications. We'll focus on leveraging two of these tools: Azure App Service and Azure Traffic Manager. 

 

Azure App Service: Azure App Service is a fully managed platform for building, deploying, and scaling web apps. With features like automatic scaling, continuous deployment, and integration with Azure DevOps, it provides an ideal foundation for hosting your web applications. 

 

Azure Traffic Manager: Azure Traffic Manager is a global DNS load balancer that enables you to distribute incoming user traffic across multiple endpoints. By directing users to the nearest or healthiest endpoint, Traffic Manager enhances the availability and responsiveness of your application. In this QuickStart, you'll read about two instances of a web application. Each of them is running in a different Azure region. You'll create a Traffic Manager profile based on endpoint priority. The profile directs user traffic to the primary site running the web application. Traffic Manager continuously monitors the web application. If the primary site is unavailable, it provides automatic failover to the backup site.

 

deniswachira_0-1693998801073.png

What You'll Learn 

  1. Provision a web application using Azure App Service. 
  2. Configure Azure Traffic Manager to distribute traffic across multiple regions. 
  3. Provision a web application using Azure App Service. 
  4. Achieve high availability and fault tolerance for your web applications. 

Our Approach: Deploying and Configuring for High Availability 

   I'll guide you through the process of deploying two same instance sample web application using Azure App Service. Each of them is running in a different Azure region. We'll then demonstrate how to configure Azure Traffic Manager to distribute traffic across different instances of the application hosted in various Azure regions. This approach ensures that your application remains available even if one of the regions experiences issues. 

Prerequisites 

For this QuickStart, you will need two instances of a web application deployed in two different Azure regions (North Europe and East Us). Each will serve as primary and failover endpoints for the Traffic Manager. 

  1. Clone this Repo https://github.com/deniswachira/azure-solution-samples 
  2. Open the folder called “azure-traffic-manager-demo” and look at the file called environment-create.sh 
  3. Sign into the Azure Portal, if you’re a student redeem Azure for students else create a free account 
  4. Launch Azure PowerShell button and select Bash. 

deniswachira_1-1693998801080.png

 

 5. Paste the script file from environment-create.sh file to the bash on azure bash cli. 

 

deniswachira_2-1693998801083.png

 

 6. Verify you have pasted the script correctly and click enter button. 

 7. Congratulation you have provisioned 2 instance of web application, one North Europe and the other in the East US. 

 

deniswachira_3-1693998801087.png

 

 8. Configure each html file instance of both web apps with the following steps. 

 9. Copy the North Europe scm endpoint and paste it on a new tab. 

 

deniswachira_4-1693998801090.png

 10. Your new tab should open like this. 

 

deniswachira_5-1693998801093.png

 

 11. Select PowerShell on debug console button. Then select site -> wwwroot then click the pen icon to edit the html 

  

deniswachira_6-1693998801096.png

 

 

deniswachira_7-1693998801100.png

 

 

 

deniswachira_8-1693998801103.png

 

  1. Paste the html code from the repo you cloned file named web-north-europe.html and click save. 

deniswachira_9-1693998801106.png

 12. Go back to North Europe web endpoint and refresh. You should have this.  

 

deniswachira_10-1693998801109.png

 

 13. Follow steps 8-11 to update the East Us instance endpoint. Use web-east-us.html file to update the instance root html file. 

14. And finally, the 2 instances should be like this. 

 

deniswachira_11-1693998801112.png

 Create a Traffic Manager profile. 

  1. Create a Traffic Manager profile that directs user traffic based on endpoint priority. 
  2. Open Azure Portal, On the upper-left side of the screen, select Create a resource. Then search for Traffic Manager profile and select Create. 

 

deniswachira_12-1693998801117.png

 

  3. Name: Enter a unique name for your Traffic Manager profile. “azure-traffic-manager-profile-demo” 

 4. Routing Method: Select Priority.

 5. Select Subscription, Resource Group and Location. 

 6. Select Create. 

 

deniswachira_13-1693998801121.png

 

Add Traffic Manager endpoints. 

  1.  Click Go to resource.  

deniswachira_14-1693998801125.png

 

Add the website in the EastUS as primary endpoint to route all the user traffic. Add the website in North Europe as a failover endpoint. When the primary endpoint is unavailable, traffic automatically routes to the failover endpoint. 

  2. In Traffic Manager profile, in the Settings section, select Endpoints, and then select Add. 

deniswachira_15-1693998801130.png

 

  3. To create a failover endpoint for your second Azure region, repeat steps 2  with these settings: 

 

deniswachira_16-1693998801135.png

 

When you are done adding the two endpoints, they are displayed in Traffic Manager profile. Notice that their monitoring status is Online, if not so wait for some moment for the changes to take effect and refresh the browser. 

 

deniswachira_17-1693998801141.png

Test Traffic Manager profile 

In this section, you will check the domain name of your Traffic Manager profile. You'll also configure the primary endpoint to be unavailable. Finally, you get to see that the web app is still available. It's because Traffic Manager sends the traffic to the failover endpoint. 

Check the DNS name 

  1. In the portal’s search bar, search for the Traffic Manager profile name that you created in the preceding section. 
  2. Select the traffic manager profile. The Overview appears. 

The Traffic Manager profile displays the DNS name of your newly created Traffic Manager profile.

 

deniswachira_18-1693998801147.png

 

View Traffic Manager in action 

  1. On a web browser, enter the DNS name of your Traffic Manager profile to view your Web App's default website. 

Note: In this QuickStart scenario, all requests route to the primary endpoint because it is set to Priority 1. 

 

deniswachira_19-1693998801149.png

 

      2. To view Traffic Manager failover in action, disable your primary site: 

      3. In the Traffic Manager Profile page, from the Overview section, select eastUSmyPrimaryEndpoint. 

      4. In eastUSmyPrimaryEndpoint, select Disabled > Save. 

  

deniswachira_20-1693998801153.png

 

      5. Close eastUSmyPrimaryEndpoint. Notice that the status is Disabled now. 

 

deniswachira_21-1693998801158.png

 

    6.Copy the DNS name of your Traffic Manager Profile from the preceding step to view the website in a new web browser session. 

     7. Verify that the web app is still available. The primary endpoint isn't available, so you were routed to the failover endpoint. 

 

deniswachira_22-1693998801162.png

 

Clean up resources 

When you're done using the private link service, delete the resource group to clean up the resources used in this QuickStart. 

  1. Enter “azure-traffic-manager-introduction” in the search box at the top of the portal,  and select “azure-traffic-manager-introduction” from the search results. 
  2. Select Delete resource group. 

Conclusion: Delivering Uninterrupted Experiences 

In the ever-evolving digital landscape, delivering exceptional user experiences is non-negotiable. Users expect applications to be available, responsive, and reliable always. Achieving this level of reliability requires a strategic approach to high availability, and Azure provides the tools to make it happen. 

 

Through this guide, we have explored how Azure App Service and Azure Traffic Manager can be your allies in the quest for high availability. By leveraging the power of these services, you have learned how to architect your applications for redundancy, failover, and global responsiveness. 

Remember that high availability is not just a technical checkbox—it is a commitment to delivering uninterrupted value to your users and customers. As you apply the principles and techniques outlined in this blog post, you are taking a significant step towards building a robust and dependable application infrastructure. 

Next steps 

Whether your application is a business-critical enterprise system, a customer-facing e-commerce platform, or anything in between, the concepts covered here are applicable and adaptable. As technology continues to evolve, Azure's ecosystem will undoubtedly expand, offering even more ways to enhance availability and resilience. 

So, go forth and implement what you've learned. Deploy your web applications with confidence, knowing that you have the tools to keep them available and performant. Embrace the journey of continuous improvement and innovation as you deliver experiences that delight your users in a world that never stops moving. 

Thank you for joining us on this exploration of high availability in the Azure cloud. Your commitment to learning and your dedication to delivering excellence are what drive progress in the digital age. 

To learn more about Traffic Manager and Load Balancing:

Co-Authors
Version history
Last update:
‎Sep 06 2023 05:09 AM
Updated by: