With this post I hope to save you some valuable debugging time when you unexpectedly 💥 encounter the Kentico Installer when opening the CMS or in case of viewing MVC see the following yellow screen error message:
Cannot access the database specified by the 'CMSConnectionString' connection string. Please install the database externally and set a correct connection string.
Alternatively, you can use web.config key CMSWaitForDatabaseAvailable or set property CMSApplication.WaitForDatabaseAvailable prior to the API initialization to let the application intentionally wait until the database is ready.
Let me start by pointing out what the issue was, namely the lack of the settings keys in my Kentico database. 😮
In my case I had restored the Kentico content and objects using the continuous integration cli with the following conflicts:
- the CI repository folder did not contain the Kentico settings keys
- the repository.config file did not mark the cms.settingskey as excluded object type
When you run the ContinuousIntegration.exe -r command with this setup then you can say goodbye 👋 to your Kentico settings.
At first I did not directly notice the issue because most of the settings are still cached when working with the CMS. It was after restarting the server that I faced the "Cannot access the database" error message.
I will leave out how our source control got in this state and directly jump to some tips that helped me figure out what went wrong. 😜
The yellow screen error message mentions the application setting: CMSWaitForDatabaseAvailable. This obviously did not fix my setup and instead got me on the wrong track thinking that my MVC application could not access the Kentico database.
In case that your setting keys are fine it might be worth to check if your application is being blocked by the firewall hence not having access to the SQL database. In Azure this can be verified in the SQL Server Azure resource within the Firewalls and virtual networks tab. Check for the setting Allow Azure services and resources to access this server and verify that it is enabled.
When I noticed the Kentico installer screen when navigating to the CMS, I figured that their might be something broken in the database. I looked for a way to compare my database with a working copy and found about the Schema Compare feature in Visual Studio:
The tool was easy to configure and gave a good overview of the differences as in my case the missing settings keys.
In this post I informed you on how I ran into a mistake by restoring the objects using the Kentico Continuous Integration CLI. How after facing the error messages it got me on the wrong track looking into database connectivity issues. And how in the end I checked a number of things and found out that the problem was related to missing Kentico settings keys. Thanks for reading. 😊