How to backup your database to a storage account using a managed identity ?

How to backup your database to a storage account using a managed identity ?

What if I told you that we can export your database to a storage account, automatically using a managed identity ? the rest is just below

Prerequisites

You will need:

In Storage Account, enable « Allow Azure services and resources to access this server« :

Deployment

First step, we will create our Managed Identity.

Go to Managed Identities and click on Create:

Fill in the requested fields.

Once the identity is created, go to Azure Role Assignments:

and apply the Contributor role to it:

Then go to Automation Account in Identity and select User assigned and click Add to add your previously created Identity:

Once finished, go to my github page:

-azure-backupsqldatabase/Export DB PAAS By Automation Account.ps1 at main · technicalandcloud/-azure-backupsqldatabase (github.com)

Retrieve the Code and put it in a Runbook:

Remember to change the client ID of your Managed Identities:

Once finished, we can save and launch the execution:

Fill in the different fields mentioned on the right:

Once completed and launched, we can return to the SQL Server, we see an export in progress :

If we go back to our storage account, we can see our .BACPAC file in our container:

Then, we can go to automation account -> Schedule, to automate the export:

Conclusion

Now you know How to backup your database to a storage account using a managed identity, and you can make the export automatic.

Nicolas VACCARO

Passionnée par l'environnement Cloud, je propose des articles qui pourront aider débutant comme expert.