Brian McKeiver's Blog

Kentico MVC Quick Tip - Deployment to Azure Gone Wrong


Recently I was asked to help out with a strange issue that my team had with deploying a Kentico MVC site to an Azure App Service. At first glance everything appeared to have been deployed correctly using the documented process for deploying Kentico MVC sites to Azure. The first request brought up the normal invalid license screen that most new deployments start out with. Clicking on the add license button correctly routed us to the Kentico admin screen, and we were able to login using the administrator credentials. But that's when things got weird.

Instead of being brought to the normal Kentico Licenses application to enter the new license, we were presented with an empty dashboard and 20+ console errors in the browser. 


The Scenario / Issue

The main issue is shown in the screen shot below. As you can see the Kentico admin interface compiled and was coming up without a hard .NET exception. But nothing was actually click-able, the Kentico logo, and any of the other home, help, or sign-out buttons did nothing. The only thing that happened was the annoying javascript:void(0); declaration showing up in the status bar. 


Kentico Menu Javascript Error


I tried just about everything I could think of to make sure it was not a client side browser cache issue. This included clearing cookies, local cache, performing a hard reset, and even trying IE and Edge instead of my trusty friend Chrome (I know...I know... I shudder at this thought too).

Upon further inspection, and hitting F12 in Chrome, the console errors revealed the story. The main cause was the fact that the macro that Kentico seems to use to determine the root application path that the site is running at was not resolving in the main calls that the admin dashboard makes. The unresolved macro was still in the URL to the client resources that power the main menu. The raw macro was just not getting resolved. I have highlighted this in the screen shot below. This should never happen.


Kentico MVC Azure Deployment Console Errors Small


Again, just to be clear, the problem was that the URL to the main menu javascript was being rendered as:


Instead of the proper:


At least I understood what the problem was at this point. Now I'm not exactly sure what might have caused this, but I at least had some data point to go from. The strange part about this issue was that running both the MVC application as well as the Kentico Admin application worked completely fine. There were absolutely no issues when we took Azure out of the equation. Even when sharing the exact same Azure SQL Database when running locally in Visual Studio worked just fine.


The Resolution

After dealing with Kentico and Azure for a few years now, my default response to issues like this is to normally just re-deploy the whole solution using the publish wizard in Visual Studio. Typically issues like this are caused by a bad deployment. However, after deploying the project again, and even for a third and fourth time, the issue persisted.  At this point I was pulling my hair out a little. It was pretty frustrating.

After walking away from my desk for a brief respite, and then consulting with a friendly technical evangelist, we decided that the issue seemed to be on the Azure side of the fence, and not the Kentico MVC side. Because of this, we tried the normal Kentico fix of re-signing macros from our local machine connection to the Azure SQL database. It turns out that this still had no effect, even after another re-deployment.

We had one tactic left at this point, and that was to clear the Kentico cache. But how could we do that when deploying the Kentico project to an Azure App Service where there was no actual Kentico menu that was functioning. It turns out that it just took a little trickery. On another installation of Kentico we just found the full URL to the System application's main frame. That relative URL happens to be ~/CMSModules/System/System.aspx in every Kentico installation, and since we were correctly authenticated the page actually loaded up on the screen just fine. I clicked the normal Clear Cache button, and boom, everything started working just fine.


So long story short, the final resolution to the Kentico admin dashboard not loading in Azure was just clearing the Kentico cache by navigating to the direct URL of


It's funny how often you can fix Kentico issues by clearing the system cache right? Somethings never change.



Can I tell you the root cause of exactly why this happened? I wish I could, but no I can not. Maybe it was a bad or partial deployment of the MVC project. Maybe it was then also complicated by the Azure App Service caching the app pool (or whatever it is in PaaS) and not wanting to let go. Who knows. But I'm hoping this blog post may save some Kentico developer out there a few hours sometime in the future.

Side note: It still amazes me how far Microsoft Azure has come with its capabilities over the last few years. Publishing an MVC web application to Azure is seriously a breeze now compared to what it used to be. I also say this because we are at the point where the majority of projects that we do at BizStream now target either the Microsoft cloud or the Amazon cloud for deployments. The cloud has finally surpassed on premise in my mind. It's about time.