In these days we had an internal discussion with our marketing department in order to increase the Azure adoption of Microsoft Dynamics NAV customers that actually never thinks to use the cloud for their business.

In my opinion, one of the first and easy way to start using some cloud services for a Microsoft Dynamics NAV customer is related to database backup. Ok, you’re a customer that never want a SaaS solution for your ERP, that is not ready for a transition of your on-premise IT infrastructure to Azure, that don’t want to move your database to the cloud. But what about your database backup?

In a totally on-premise infrastructure, your NAV database backup is normally performed directly from SQL Server (T-SQL scripts or maintenance plan) and then saved to an external storage. But why not saving it to a secured cloud-based storage and avoid to maintain also an infrastructure for backup maintenance?

Starting from SQL Server 2012, you can directly perform a database backup on an Azure Storage account (BLOB Storage) via T-SQL. This permits you to have a totally secured, redundant and very cost effective way of managing your backup files.

As an estimate of costs, a 1TB storage account Geo Redundant costs about 60$/month while Local Reduntant costs about 20$/month. Remember also that inbound data transfers to Azure are free, while outbound transfers are charged for the bandwidth use and calculated based on a graduated region-specific scale (very low cost). This is for sure less than using and maintaining a SAN or tapes.

Activating this feature on your existing on-premise SQL Server for your NAV database is extremely simple.

As a first step, you need to create a Storage Account via Azure Portal and, when created, take note of the Storage Account name and Access keys:

SQLServerAzureBackup_01.jpg

Then, you need to create a BLOB container inside this storage account (assigning it a name, for example mysqlbackupcontainer):

SQLServerAzureBackup_02.jpg

Your Azure infrastructure for hosting the database backups is now ready.

Now, in your on-premise SQL Server database, you can use the following scripts for performing a direct backup on Azure.

First step, you have to create a SQL Server Credential object for accessing the Azure Storage Account:

IF NOT EXISTS (SELECT * FROM sys.credentials WHERE credential_identity = 'AzureStorageCredential')
CREATE CREDENTIAL AzureStorageCredential
WITH IDENTITY= 'myAzureStorageAccount', SECRET = '<your storage account access key>';

where myAzureStorageAccount is the name of your Storage Account (the key can be Key 1 or Key 2 of your Storage Account Access keys).

Now, you can perform the full database backup by using the previously created credentials:

BACKUP DATABASE[MYNAVDATABASE] TO URL = 'https://myazurestorageaccount.blob.core.windows.net/mysqlbackupcontainer/MyNAVDatabaseBackup.bak'  
WITH CREDENTIAL = 'AzureStorageCredential', STATS = 5; 
GO

where myazurestorageaccount is the name of your Storage Account in Azure and mysqlbackupcontainer is the name of your BLOB storage container.

STATS = 5 option is useful to monitor the progress of the operation.

After executing this script, your full database backup will be archived in your BLOB storage container.

What about restoring?

You can perform a restore from a backup hosted in Azure in the same simple way:

RESTORE DATABASE [MYNAVDATABASE]
FROM URL = 'https://myazurestorageaccount.blob.core.windows.net/mysqlbackupcontainer/MyNAVDatabaseBackup.bak' 
WITH CREDENTIAL = 'AzureStorageCredential', STATS = 5;
GO

If you need to start “educating” a customer to embrace the cloud, this could be an interesting entry point to propose.