As part of our IT refresh we have decided to move this BlogEngine.NET server from a Hyper-V VM in our office to an Azure website.
BlogEngine.NET is now a gallery item for Azure website, so a few clicks and your should be up and running.
However, if you want to use SQL as opposed to XML as the datastore you need to do a bit more work. This process is well documented in the video ‘Set BlogEngine.NET to use SQL provider in Azure’, but we found we needed to perform some extra steps due to where our DB was coming from.
The main issue was that our on premises installation of BlogEngine.NET used a SQL 2012 availability group. This amongst other things, adds some extra settings that stop the ‘Deploy Database to Azure’ feature in SQL Management Studio from working. To address these issues I did the following:
Took a SQL backup of the DB from our production server and restored it to a local SQL 2012 Standard edition. I then tried the Deploy to Azure
But got the errors I was expecting
There were three types
Error SQL71564: Element User: [BLACKMARBLE\AUser] has an unsupported property AuthenticationType set and is not supported when used as part of a data package.
Error SQL71564: Element Column: [dbo].[be_Categories].[CategoryID] has an unsupported property IsRowGuidColumn set and is not supported when used as part of a data package.
Error SQL71564: Table Table: [dbo].[be_CustomFields] does not have a clustered index. Clustered indexes are required for inserting data in this version of SQL Server.
The first fixed by simply deleting the listed users in SQL Management Studio or via the query
DROP USER [BLACKMARBLE\Auser]
The second were addressed by removing the ‘IsRowGuidColumn’ property in Management Studio
or via the query
ALTER TABLE dbo.be_Categories SET (LOCK_ESCALATION = TABLE)
Finally II had to replace the non-cluster index with a cluster one. I got the required definition form the setup folder of our BlogEngine.NET installation, and ran the command
DROP INDEX [idx_be_CustomType_ObjectId_BlogId_Key] ON [dbo].[be_CustomFields]
CREATE CLUSTERED INDEX [idx_be_CustomType_ObjectId_BlogId_Key] ON [dbo].[be_CustomFields]
Once all this was done in Management Studio I could Deploy DB to Azure, so after a minute or two had a BlogEngine.NET DB on Azure
Azure SQL Login
The new DB did not have user accounts associated with it. So I had to create one
On the SQL server’s on Master DB I ran
CREATE LOGIN usrBlog WITH password='a_password';
And then on the new DB I ran
CREATE USER usrBlog FROM LOGIN usrBlog ;
EXEC sp_addrolemember N'db_owner', usrBlog
At this point we could have created a new Azure website using the BlogEngine.NET template in the gallery. However, I chose to create an empty site as our version of BlogEngine.NET (3.x) is newer than the version in the Azure gallery (2.9).
Due to the history of our blog server we have a non-default structure, the BlogEngine.NET code is not in the root. We retain some folders with redirection to allow old URLs to still work. So via an FTP client we create the following structure, copying up the content from our on premises server
Next I set the virtual application on the Configure section for the new website, right at the bottom, of the page
At this point I was back in line with the video, so need to link our web site to the DB. This is done using the link button on the Azure web site’s management page. I entered the new credentials for the new SQL DB and the DB and web site were linked. I could then get the connection string for the DB and enter it into the web.config.
Unlike in the video the only edit I need to make was to the connection string, as all the other edits had already been made for the on premises SQL
Once the revised web.config was uploaded the site started up, and you should be seeing it now