Deploy projects to Azure App Service

Overview

Azure App Service is one of the easiest options for developers and administrators to deploy and manage a Sitefinity website. Being a PaaS offering, App Service takes away the complexity of dealing infrastructure and servers. You can easily develop and deploy your Sitefinity website using Visual Studio, benefit from automatic high availability and configure auto-scaling while keeping the cost optimal. Azure App Service provides a secure ISO and PCI compliant environment for your Sitefinity website as well.

The following article provides guidance and insights into the recommended Azure components and services that must be used to configure a Sitefinity website in Azure.

Required components and Services

To set up your website infrastructure layer in Azure, the following components and services must be used:

  • Azure App Service with pre-configured auto-scaling to optimally handle to load of the website at any time. 

    RECOMMENDATION: For optimal performance, we recommend using Premium v2, P2V2 plan. For more information, see App Service pricing.

  • Azure SQL Database to store the website’s data, tuned to ensure top performance for the application. 

    RECOMMENDATION: For optimal performance, we recommend using Database transaction unit (DTU) S2 or S3 plans. For more information see, Azure SQL Database pricing.

  • Azure Cache for Redis used for data caching, to further optimize the website performance. Sitefinity CMS needs Redis (and Azure cache for Redis) configured, so the following mechanisms can work properly:
    • Load Balancing - To prepare the communication infrastructure to transmit messages between the nodes. For example, to communicate cache invalidation. Sitefinity CMS uses Redis message sender that must be configured for NLB communication in Azure App Service. 
    • Distributed output cache - To configure Sitefinity CMS to use distributed output cache you need to select one of the supported distributed cache providers and configure the selected provider.

      NOTE: To use Redis as your output cache storage you need to specify a valid Redis connection string. If you do not specify a connection string, Sitefinity CMS will use the one configured in Load Balancing Redis settings. For more information see: Configure Azure Redis cache

The following diagram demonstrates how the components fit together:

Azure App Service diagram

Optionally, you can configure additional components, like Azure search and Azure CDN, Azure Monitor, to take care of content indexing,  search and live site performance. Solutions from other vendors can be used as well.

Benefits of using Azure App Service

Deploying your Sitefinity website to Azure App Service provides the following benefits:

  • High availability
    The App Service multi-region architecture can provide higher availability than deploying to a single region. If a regional outage affects the primary region, you can configure Azure to fail over to the secondary region. This way Azure automatically takes care of high availability and provides a 99.95% SLA. Deployment slots  and pipelines enable developers to build a CI/CD pipeline where changes to your Sitefinity website are first  deployed to a staging environment and tested there before swapping to production.
  • Auto-scaling
    If configured to scale up, Azure App Service can dynamically allocate resources to match performance requirements. As the number of website visitors and requests to your website grows, Sitefinity CMS may need additional resources to maintain the desired performance levels. Autoscaling takes advantage of the elasticity of cloud-hosted environments and automatically decides whether to add or remove resources.
  • Cost management
    You can benefit from Azure’s pay-as-you-go pricing model, which is very effective especially for small and medium enterprises, since you pay only for the services that are active in your Azure account. App Service also has built-in load balancers that help save infrastructure costs.
  • Security
    In addition to the security mechanisms provided by the Sitefinity Web security module, Azure App Service also provides Infrastructure and platform security. App service also comes with layered security like multi-factor authentication and is ISO and PCI compliant.
  • Easy integration with Visual Studio
    App Service integration with Visual Studio makes it easy for developers to customize and quickly deploy Sitefinity projects to the cloud. Azure automatically handles deploying your code to multiple servers and high availability.  For more information see Publish your project to Azure App Services.

Host Sitefinity CMS on App Service behind Application Gateway

When you use App Service behind an Application Gateway, there is one specific detail which should be handled. A request hits the App Service, using its internal domain - *.azurewebsites.net.  When the application gateway forwards your request to the backend pool, it also forwards X-Original-Host HTTP header, where it stores the domain from the original request. This is a problem for Sitefinity CMS and for every web app that depends on the original request host.

This problem can be handled by rewriting the value from the custom HTTP header used from the Application Gateway (X-Original-Host) to the original HTTP host header (Host). 

To do this, install the following App Service extension:

https://www.nuget.org/packages/AppGatewayHostRewriteModule/
The extension uses a native C/C++ module registered in the IIS global modules. The module sets the HOST header to the X-Original-host value. It should be installed from the Kudu Site extensions.

IMPORTANT: This extension works only for App Service that is configured for x64 bit platform.

After installing the App Service extension, restart the App Service, so that the changes can take effect.

NOTE: You can rewrite the Host header with the value of X-Original-Host header by first unlocking the Host and X-Original-Host headers, so that you can rewrite them using rewrite rules. Then, when the request reaches the App Service, the value of Host header is set to the value of X-Original-Host header. However, this approach has one general pitfall, if there are other rewrite rules executed after the rule for rewriting the Host header, they do not respect the new value of Host header. Using the native module, ensures that Host header has taken the value of X-Original-Host header before the rewrite module steps in.

Considerations when using Azure App Service

The Azure App Service architecture introduces a few limitations that developers and website administrators must be aware of, when planning to deploy their Sitefinity website to the cloud. Unlike the traditional approach where you have access to the application files and can remotely access the server running your Sitefinity website, in App Service the Remote desktop option is not available. This means that you cannot directly inspect/edit application files, install monitoring software on the server, and so on. Custom code is deployed via Visual Studio, Git, and so on. Application logs, resource and performance monitoring, and profiling is done via the Azure portal.

Additional resources

Azure videos

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?