Deployment Options for Kentico MVC Sites to Azure App Services

   —   

As MVC becomes the main development model for Kentico developers, understanding how to host your applications becomes an important skill to master. Depending on your hosting environment, your application structure can have a significant impact on your ability to scale, update, and manage your projects. With more and more companies considering Azure App Services, I wanted to give you my thoughts on how to best use the platform for your Kentico MVC sites.

When I started at Kentico a few years ago I remember attending events and discussing development models with partners from around the world. I used to ask, “How many of you do MVC sites?” Back then, I’d have 1 or 2 hands go up, as most were still focused on traditional Web Forms. The next year, it was 20-30% of the crowd. A year ago, it was a little over half. These days, it’s becoming the majority who look at an MVC model first when they’re developing their applications.

With MVC, companies can better define their development process. They can isolate functionality for backend developers to work on, which allows designers to do whatever magic they do to make things look good. After the learning curve, it’s really a powerful methodology, which is why so many teams are adopting it.

Over the same time, Azure has exploded in popularity. With new features being released (seemingly) every day, it’s no wonder that companies are beginning to deploy every application they can to the cloud. With Azure App Services, Microsoft has simplified web hosting, allowing developers to deploy their applications with a few clicks. Long gone are the days of standing up and configuring a server. Now, it’s choosing Publish in Visual Studio and creating an App Service on the fly.

With both concepts gaining so much traction, I wanted to provide some guidance on how you can leverage both for your projects.

Azure App Service basics

Before I get into the options, I wanted to make sure you had a solid understanding of what Azure App Services are. I see them as a simplified web hosting model, allowing developers to deploy applications quickly and configure the basic aspects of the environment. With App services, companies can set environmental variables, default documents, and integrate with external systems. While they don’t offer direct server access, App Services do provide a commoditized option for applications and a lot of cost savings to go along with them.

Every App Service is part of an Azure App Service Plan. This allows you to group multiple App Services together, simplifying your application management and hosting.

You can read more about Azure App Services Plans here.

Here’s a list of the major benefits:

  • Single price for all App Services in App Service Plan
  • Shared resources across all app services
    • Memory
    • Storage
    • CPU
  • Integration with source control
  • Customizable hosting environment

Now that you understand what Azure App Services are, let’s talk about your options when it comes to hosting your Kentico MVC sites.

Option 1- Single App Service with nested admin site

In this scenario, you have a single Azure App Service, which runs both the Kentico Admin site and the MVC site. This gives you a single site codebase, containing both your MVC code, as well as your Kentico admin UI.

Typically, you will have your MVC site as the root, as this is your public-facing content. In Visual Studio, you could configure your Publish Settings to deploy directly to your Azure App Service.

Publish Settings - MVC

For the Kentico installation, you can configure Publish Settings to deploy to a subfolder in your site. In my case, this is the cms folder.

Publish Settings - CMS Nested

Because the Kentico site is its own application, you need to configure it as a virtual application in the Azure Portal. In your Azure App Service, go to Application Settings and create a virtual directory for your subfolder.

Application Settings - Nested

In Azure, you will have a single App Service in your dashboard.

Azure Dashboard - NEsted

Once you have both sites deployed, you can access them via the App Service URL.

Here is the MVC site at the root of the URL.

MVC Site

Here is the Kentico site in the cms directory.

Admin Site - Nested

Pros

  • Manage a single Azure App Service
  • Leverage Application Settings within the Azure App Service to store values used in both applications (connection strings, passwords, etc.)
  • Utilize a single domain for both applications

Cons

  • Because both applications use the same app pool, restarting brings down both applications
  • Deployment from source control requires additional configuration for nested applications (specifying folders, etc.)
  • Combined authentication, backup, networking, and other App Service settings
  • Combined reporting (cannot determine which application is consuming resources)

Note

If you use a nested Kentico Admin site, your media libraries will be synced between the two via the web farm sync. In this case, you will have a media library folder in your "nested" CMS site, as well as you "root" MVC site. This isn't necessarily an issue, but I though it was worth noting. You could configure the site to use Azure Storage for the media library, which would eliminate this redundancy.

A big shout-out to MVP Brian McKeiver at BizStream and Rui Wang on the Kentico Consulting team for helping with the nested setup details!

Option 2 -Separate App Services for MVC / Admin sites

In this scenario, you deploy the Kentico Admin and MVC sites as separate App Services within the same App Service Plan. Each site contains only its files and runs independently.

In Visual Studio, your Publish Settings for the MVC site will be the same.

Publish Settings - MVC

For the Kentico Admin site, you can set the Publish Settings to deploy to its own URL.

Publish Settings - CMS Seperate

In your Azure Dashboard you will have 2 App Services, one for each application.

Azure Dashboard - Seperate

Once deployed, you will access the MVC site, same as before.

MVC Site... again

Because the Kentico Admin site is a separate application, you can access it by its unique URL.

Admin Site - Seperate

Pros

  • Isolation of each application. This allows you restart one of the applications without affecting the other.
  • Independent reporting on each application
  • Each application can be configured to deploy from source control
  • No virtual applications to create
  • Each application runs as a separate Azure App Service so Authentication, deployment credentials, and other settings can be unique

Cons

  • Potential duplication of Application Settings across both Azure App Services
  • Requires an additional URL for the MVC application (ex: www.company.com) and Kentico Admin application (ex: admin.company.com)

Note

Because this scenario has a separate URL for the MVC site, you will need to contact your Kentico Sales Rep to generate a new license. This is included in the base price of the product so there is no additional charge for this license.

My recommendation

Because of how Azure App Services function and are priced, my recommendation is Option 2 -Separate App Services for MVC / Admin site. With both options, you are paying the same amount, and the same amount of resources are available to each site. With this option, you can isolate your applications, update them independently, and configure them separately within the Azure Portal. You can also set unique properties for Authentication, Backups, and other App Service-level settings. This provides a lot of flexibility when tailoring the hosting for the MVC and Admin sites.

Moving forward

One of the best parts about Azure is its flexibility and scalability. By leveraging the platform features, you can customize your hosting and deployment environments to fit nearly any business need. With Azure App Services, you can simplify your application hosting, gain the benefit of some extremely powerful integrations, and reduce your site administration across your organization.

Have questions about this or other Azure topics? Let me know in the comments!  Good luck!

Bonus!

As part of this blog, I created the new Azure App Services and placed them in my existing Azure App Service Plan (that I used for other demos). Because the plan is billed a single cost for all resources, adding these new App Services did not increase the monthly charge. I created a database for testing, and then deleted a day later. This means I only paid for the DB for about 24 hours. At $0.0068 / hour for a Basic DB, the total cost was approx. $.16!  Azure FTW!

Share this article on   LinkedIn Google+

Bryan Soltis

Hello. I am a Technical Evangelist here at Kentico and will be helping the technical community by providing guidance and best practices for all areas of the product. I might also do some karaoke. We'll see how the night goes...