This article will give a quick description for how to set up recurring Dynamics 365 SQL DB backups from a Tier 1 environment to an Azure storage account.
Sign in to your Tier 1 environment and run SQL Server Management Studio (SSMS) as Admin. Connect to your server.

Right click the AxDB data base and select Tasks > Back Up…

Keep the source information the same, and set the destination information to back up to “URL.” Click “Add.”

Select “New container.”

Click “Create Credential.”

Click “OK” again, and you will see your URL in the destination block.
Optional: Under “Backup Options” change “Set backup compression” to “Compress backup.”

Under the “General” tab, select the “Script” drop-down. Choose “Script Action to Job.”

On the left-hand side, click “Schedules.”

Click “OK.” You should see in the bottom left-hand corner that “Scripting completed successfully.” Click “OK.” This will execute the job. We are not done with our configurations, but a backup will be taken at this time and placed on the Azure storage account container you selected.

After clicking “OK” you should see that the backup successfully completed.

On the right-hand side, under “Jobs,” find your job “Back Up Database – AxDB.”

Click “Steps” in the left-hand column. Then click “Edit.”

DECLARE @FileLoc NVarchar(100) = CONCAT(‘https://<YOURURL>/axdb_backup_’,format(getdate(),’yyyyMMddHHmmssffff’),’.bak’)BACKUP DATABASE [AxDB] TO URL = @FileLoc WITH NOFORMAT, NOINIT, NAME = N’AxDB-Full Database Backup’, NOSKIP, NOREWIND, NOUNLOAD, STATS = 10Click “OK” to save the changes.

Now we will wait for our job to run. After it does (on a schedule or manually), we can go to the Azure portal storage account and look for our backup.

Using the jobs properties, we can configure alerts for failures. This way we can get emails if an issue occurs. This config is out of the scope of this document but is handy to know that there are options available here. SSMS jobs also provide additional logging of previous runs, to help debug possible issues.

In the Azure portal, we can select the storage account we are interested in sending on backups too.
From the left-hand side, select “Lifecycle management” then click “Add rule.”

Name your rule “RetentionPeriod” and click “Next.”

Set the number of days to keep a blob before deleting it.

This is a quick and useful way to avoid keeping every back up file.
Set the SQL Server Agent to start automatically to avoid needing to manually start the service after an environment restart.

For more D365 expert advice, contact us today.
Post originally published https://markedcode.com/index.php/2022/08/24/sql-backup-to-azure/
This publication contains general information only and Sikich is not, by means of this publication, rendering accounting, business, financial, investment, legal, tax, or any other professional advice or services. This publication is not a substitute for such professional advice or services, nor should you use it as a basis for any decision, action or omission that may affect you or your business. Before making any decision, taking any action or omitting an action that may affect you or your business, you should consult a qualified professional advisor. In addition, this publication may contain certain content generated by an artificial intelligence (AI) language model. You acknowledge that Sikich shall not be responsible for any loss sustained by you or any person who relies on this publication.