https://github.com/oxhobbs/azure-apim-backup-restore
https://github.com/oxhobbs/azure-apim-backup-restore
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/oxhobbs/azure-apim-backup-restore
- Owner: OxHobbs
- Created: 2020-08-21T19:51:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-21T22:07:57.000Z (over 5 years ago)
- Last Synced: 2025-01-22T09:51:22.760Z (11 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Azure API Management Backup/Restore
## Overview
This project has two command line scripts that provide the functionality of
performing a backup/restore of an Azure API Management instance. It works by
using the Python SDK to perform a backup/restore option to backup/restore to/from
an Azure Storage Account.
Authentication is handled via a service principal.
Some reasons to backup an API management instance could be for the following:
* Disaster Recovery scenarios
* Migrating an Azure APIM instance to another region
* Migrating an Azure APIM to a new tenant and subscription
## Usage
### Pre-reqs
* Python 3
* `azure-mgmt-apiinstance` package
* Service Principal with permissions to the Azure APIM instance and the storage account where
the backup will be stored.
### Parameters
#### apim_backup.py
**NOTE**: The service principal parameters may be provided via environment variables rather than interactively
through the CLI. The environment variables are: CLIENT_ID, CLIENT_KEY, TENANT_ID and SUBSCRIPTION_ID.
Arguments provided via the CLI take precedence over environment variables.
- `-g, --resource-gorup`: Resource group that contains the API Management instance
- `-n, --name`: The name of the API Management instance to be backed up
- `--storage-account`: The name of the storage account where the backup will be stored
- `--container`: The storage account container where the backup file will be stored
- `--storage-account-key`: The key to the storage account
- `--client-id`: The client ID of the service principal
- `--client-key`: The secret key for the service principal
- `--tenant-id`: The tenant ID for the service principal
- `--subscription-id`: The subscription ID where the APIM instance is hosted
##### Examples
```bash
# CLIENT_ID, CLIENT_KEY, TENANT_ID, SUBSCRIPTION_ID all stored in environment vars
apim_restore.py -g "apim-rg" -n "apim-instance" --storage-account "apimsa" --container "backups" --storage-account-key ""
```
```bash
apim_restore.py -g "apim-rg" -n "apim-instance" --storage-account "apimsa" --container "backups" --storage-account-key "" \
--client-id --tenant-id --subscription-id --client-key
```
#### apim_restore.py
**NOTE**: The service principal parameters may be provided via environment variables rather than interactively
through the CLI. The environment variables are: CLIENT_ID, CLIENT_KEY, TENANT_ID and SUBSCRIPTION_ID.
Arguments provided via the CLI take precedence over environment variables.
- `-g, --resource-gorup`: Resource group that contains the API Management instance
- `-n, --name`: The name of the API Management instance to be restored
- `--storage-account`: The name of the storage account where the backup is stored
- `--container`: The storage account container where the backup file is stored
- `--backup-file-name`: The name of the backup file to be used for restoration
- `--storage-account-key`: The key to the storage account
- `--client-id`: The client ID of the service principal
- `--client-key`: The secret key for the service principal
- `--tenant-id`: The tenant ID for the service principal
- `--subscription-id`: The subscription ID where the APIM instance is hosted
##### Examples
```bash
# CLIENT_ID, CLIENT_KEY, TENANT_ID, SUBSCRIPTION_ID all stored in environment vars
apim_restore.py -g "apim-rg" -n "apim-instance" --storage-account "apimsa" --container "backups" --backup-file-name "apimbackup08020414 --storage-account-key ""
```
```bash
apim_restore.py -g "apim-rg" -n "apim-instance" --storage-account "apimsa" --container "backups" --backup-file-name "apimbackup08020414 --storage-account-key "" \
--client-id --tenant-id --subscription-id --client-key
```