Migrating a DNN (Dotnetnuke) site to the Cloud Part 3
Scenario
The Azure App Service has been configured and we are now ready to proceed with the actual migration of old to new. This has four main parts:
- Migrate the database
- Migrate the files
- Update the database connection string
- Verify the migration
Preparation
As it is a lot easier to migrate a website that is not being constantly changed, it is preferable to arrange a time for the migration when no changes are being made to it. This may not be possible, of course, but if this is not done, you will have the additional task of synchronising your data before you can bring the Azure version of your website live.
The user accounts and passwords for the Azure database and FTP server will also be needed. These can be found in your Azure portal. You will also need to know the IP address of the computer that you will be using for the migration as this will need to be added to the firewall exception list on the Azure SQL server.
As the database connection string will change when your DNN portal is migrated into Azure, it will be necessary to update the web.config file in the root directory after the file upload has completed.
Tools
Although, due to the lack of sufficient dbo rights in the source SQL database, the SQL Management Studio cannot be used to migrate the database into Azure, it will still be useful to verify that the SQL migration has gone to plan. Having the SQL Management Studio and its related desktop tools available will also help should any problems arise during the migration of the SQL database.
A copy of the SQL Migration Wizard will also be required as this is the tool that will be used to do the SQL migration. This is available as a free download from Codeplex. The tool will allow the source database to be exported for import directly into Azure. This may seem old school but it is viable, if slow, option when other options are not available.
As the total size of the files used by the source website was small, the decision was taken to simply copy them by FTP to the Azure version of the website. There were, however, a large amount of small files - this is common to DNN as well as other .NET based applications – so the file overhead of copying everything would have substantial and therefore substantially extend the time needed to complete the upload. Therefore, the files were to be compressed into a zip file, copied up and decompressed in Azure. The zip file, in this case, from the backup taken with the Evotiva software used within the source portal although the zip file could simply be made by downloading the DNN files to a local disk and zipping them.
Database migration
Before migrating the database, it is necessary to add a portal alias to the source DNN portal that matches the name of the Azure App Service web application that you created. This will not affect the functioning of the source DNN portal and will allow you to access the Azure version of the DNN portal once it has been migrated in order to test its functionality. The Portal alias can be added in Manage – Sites - Site Settings = Site Aliases when logged in as host to your source DNN portal.
It is also necessary to add the IP address of the computer that will be used for the migration. Note that this is your public IP address so, if you are behind a firewall, it will not be the IP address retuned by the local ipconfig command. Migrating the DNN SQL database using the SQL Migration Wizard can be slow as it involves an export of the database and then an import to Azure. The great advantage of the tool is that it can spot and correct the vast majority of SQL related issues that might delay or destroy your plans for a smooth and uneventful migration
Connect to your source server.
The export will now commence. A log is generated as the export takes place. Once completed, it is important to check the log so that any errors can be identified and rectified. For this migration, the only error recorded is shown below:
StoredProcedure [dbo].[Dashboard_GetDbBackups] -- backupset is not supported in current version of Azure SQL Database
StoredProcedure [dbo].[Dashboard_GetDbBackups] -- 'DB_NAME(' is supported only for the local database. You should test to verify the results are what you want.
StoredProcedure [dbo].[Dashboard_GetDbFileInfo] -- sys.database_files is not supported in current version of Azure SQL Database
StoredProcedure [dbo].[Dashboard_GetDbFileInfo] -- sys.database_files is not supported in current version of Azure SQL Database
These errors requires no action and will not affect the import of the DNN SQL database into Azure. Connect to the Azure SQL database to begin the import.
The import will now begin. Once that is completed, check the logs to verify that everything has completed.
File migration
The compressed zip file containing the files used by your portal can be uploaded using your favourite FTP software. Remember to upload the file to the correct folder - \site\wwwroot and not the root of the site.
Once the zip file has uploaded, the file can be unzipped. As there was no option in the graphical interface to do this, this had to be done using the command line in the Kudu console. This is accessed from a web browser https://xxxxxx.scm.azurewebsites.com where xxxxxx represents the name of your Azure web application and then selecting Debug Console and then CMD.
Once the files have been decompressed, edit the web.config file in \site\wwwroot and edit the web.config file to change to connection string by searching for the “SiteSQlServer” key and replacing the existing connectionstring with the database connection details for your Azure database.
The key should then look similar to the following:
add name="SiteSqlServer" connectionString="Data Source=tcp:xxxxxxx.database.windows.net,1433;Initial Catalog=xxxxxx;User Id=xxxxxx@xxxxxx.database.windows.net;Password=xxxxxx;"
Where “xxxxxx” represents the details from your Azure database connection string. Save the changes and upload the web.config. This will restart the DNN application in Azure. Wait a few minutes for this process to complete and you should then be able to access your DNN application in Azure using https://xxxxxx.azurewebsites.net xxxxxx represents the name of your Azure web application and test that it actually works
Next time – taking your Azure installation of DNN live.