Backup Azure API Management
You may be deploying your Azure API Management service via Azure DevOps, giving you the ability to redeploy at a moment’s notice. You may have the ability to bring it back up in if it totally tips over or redeploy quickly into another region if there is an issues with your primary one. But, while that will contain all of your API definitions, what cannot be captured in your release pipeline are the configuration data within APIM.
If you use APIM for authentication, for users/subscribers to create accounts and such, those items are not cataloged in your APIM definition in DevOps. Enter Backup-AzureAPIM.ps1. I found the script Gist written by Andreas Botsikas. It promised to work pretty swimmingly, but I kept getting errors around APIM resource group not found. I was able to make a quick edit. Since Github doesn’t let you create a pull request on a Gist, I forked it, updated it, and notified Andreas.
It’s super easy to plug this script into an Azure Automation Account, schedule it, and pump the backups to Blob Storage. I show you how to do it here.
You can find the working APIM backup script at my Gist located here. Please come back and comment here if you end up using this script.