Deploying a Hybrid App with On-Premises Data and Cross-Cloud Scaling

In this comprehensive guide, we’ll walk through the process of deploying a hybrid application that leverages both Azure and Azure Stack Hub to create a scalable and resilient solution. By combining the benefits of a private cloud (Azure Stack Hub) with the scalability of the public cloud (Azure), you can build applications that meet your organization’s compliance requirements while still taking advantage of the cloud’s elasticity.

Understanding the Hybrid Cloud Approach

The key to this solution is the hybrid cloud architecture, which allows you to seamlessly integrate your on-premises resources with the public cloud. This approach offers several advantages:

  1. Compliance Benefits: By hosting sensitive data and resources on Azure Stack Hub, you can maintain tight control and adhere to stringent compliance requirements, while still leveraging the public cloud for scalability and flexibility.

  2. Developer Productivity: Your developers can utilize the extensive Microsoft ecosystem and apply their existing skills to both cloud and on-premises environments, maximizing their efficiency and productivity.

  3. Scalability and Resilience: When your application experiences a surge in traffic, the solution can automatically scale out to the public cloud, ensuring a seamless user experience. Once the traffic subsides, it can scale back in, optimizing your costs.

Solution Overview

In this tutorial, you’ll learn how to:

  1. Deploy a hybrid-connected SQL Server database server on Azure Stack Hub.
  2. Connect a web app in Azure to the hybrid network, enabling communication with the on-premises data source.
  3. Configure DNS and SSL certificates to enable cross-cloud scaling.
  4. Set up the web app and its deployment, including dynamic connection strings and Application Insights integration.
  5. Create a Traffic Manager profile and configure it to seamlessly route traffic between Azure and Azure Stack Hub.
  6. Implement Application Insights monitoring and alerting to trigger automatic traffic switching between the two cloud environments.
  7. Configure both manual and automatic methods for redirecting traffic between Azure and Azure Stack Hub.

By the end of this guide, you’ll have a robust, cross-cloud solution that combines the benefits of a private cloud with the scalability and elasticity of the public cloud.

Prerequisites

Before you begin, ensure you have the following in place:

  • An Azure Stack Development Kit (ASDK) or a subscription on an Azure Stack Hub Integrated System.
  • Your Azure Stack Hub environment should include the Azure App Service, Windows Server 2016 images, and a Windows Server 2016 with SQL Server image.
  • A domain name for your web app and an SSL certificate from a trusted authority like LetsEncrypt.
  • A web app that communicates with a SQL Server database and supports Application Insights.
  • A hybrid network between Azure and Azure Stack Hub.
  • A hybrid CI/CD pipeline with a private build agent on Azure Stack Hub.

Deploying the Hybrid-Connected SQL Server Database Server

  1. Sign in to the Azure Stack Hub user portal and navigate to the Marketplace.
  2. Select the ‘Free SQL Server License: SQL Server 2017 Developer on Windows Server’ image and create a new virtual machine.
  3. Configure the basic settings, such as the VM name, SQL Server admin user, and subscription details.
  4. Select the appropriate VM size and configure the optional features, including the virtual network, network security group, and storage account.
  5. In the SQL Server settings, enable public connectivity and SQL authentication.
  6. Review the summary and deploy the SQL Server VM.

Creating Web Apps in Azure and Azure Stack Hub

Next, you’ll create web apps in both Azure and Azure Stack Hub to host your application.

  1. Create a web app in Azure using the App Service.
  2. Repeat the process to create a web app in Azure Stack Hub.
  3. Ensure the Azure Stack Hub web app is accessible from the public internet by configuring a static NAT mapping (if using the ASDK).

Connecting the Azure Web App to the Hybrid Network

To enable communication between the web app in Azure and the SQL Server database in Azure Stack Hub, you need to configure a point-to-site VPN connection.

  1. In the Azure portal, configure the point-to-site settings on the virtual network gateway.
  2. Integrate the Azure App Service app with the hybrid network by following the instructions for gateway-required VNet integration.
  3. Configure the local network gateway in Azure Stack Hub to route traffic from the App Service point-to-site address range.

Configuring DNS and SSL for Cross-Cloud Scaling

To enable users to access your web app instances in both Azure and Azure Stack Hub, you’ll need to set up custom domains and SSL certificates.

  1. Create subdomains for the Azure and Azure Stack Hub endpoints, such as app.northwind.com and azurestack.northwind.com.
  2. Configure the custom domains in Azure and Azure Stack Hub, mapping a CNAME record for the Azure endpoint and an A record for the Azure Stack Hub endpoint.
  3. Add SSL certificates to both the Azure and Azure Stack Hub web apps to secure the data in transit.

Configuring and Deploying the Web App

Prepare the web app code to report telemetry to the correct Application Insights instance and configure the connection strings for the Azure and Azure Stack Hub environments.

  1. Integrate Application Insights into your web app project.
  2. Modify the app’s connection strings to use environment variables, allowing you to specify different connection details for each cloud environment.
  3. Configure the app settings in Azure and Azure Stack Hub to include the appropriate connection strings.

Enabling Automatic Scaling in Azure

To handle traffic spikes, you’ll set up automatic scaling for the web app in Azure.

  1. Configure automatic scale-out to add instances when the CPU utilization exceeds 50% over a 10-minute period.
  2. Set up automatic scale-in to reduce instances when the CPU utilization drops below 30% over a 10-minute period.

Creating a Traffic Manager Profile and Cross-Cloud Scaling

To manage the routing of traffic between Azure and Azure Stack Hub, you’ll create a Traffic Manager profile and configure the endpoints.

  1. Create a new Traffic Manager profile in the Azure portal.
  2. Add the Azure and Azure Stack Hub web app endpoints to the profile, configuring the appropriate settings for each.

Implementing Application Insights Monitoring and Alerting

Use Azure Application Insights to monitor your application and set up alerts to trigger automatic traffic switching.

  1. Create a scale-out alert that triggers when the request rate exceeds 2 requests per 5 minutes.
  2. Create a scale-in alert that triggers when the request rate drops below 2 requests per 5 minutes.
  3. Configure the alerts to use webhooks that call an Azure Function to enable or disable the appropriate Traffic Manager endpoints.

Redirecting Traffic Between Azure and Azure Stack Hub

You can configure both manual and automatic methods for switching traffic between the two cloud environments.

  1. For manual traffic redirection, use the Azure portal to enable the Azure endpoint and disable the Azure Stack Hub endpoint when you receive an alert.
  2. For automatic traffic redirection, use the Azure Function developed in the previous step to toggle the Traffic Manager endpoints in response to the Application Insights alerts.

By following this comprehensive guide, you’ll have a resilient, cross-cloud application that leverages the benefits of both Azure and Azure Stack Hub, seamlessly scaling to meet your users' needs while maintaining compliance with your organization’s requirements.

Resources