Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit aecd9ce

Browse files
Juliakoerickson-doug
authored andcommitted
added backup script (#94)
* added backup script * moved a file
1 parent 44829e9 commit aecd9ce

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
##########################################################
2+
# Script to backup and restore api management service.
3+
###########################################################
4+
5+
$random = (New-Guid).ToString().Substring(0,8)
6+
7+
#Azure specific details
8+
$subscriptionId = "my-azure-subscription-id"
9+
10+
# Api Management service specific details
11+
$apimServiceName = "apim-$random"
12+
$resourceGroupName = "apim-rg-$random"
13+
$location = "Japan East"
14+
$organisation = "Contoso"
15+
$adminEmail = "[email protected]"
16+
17+
# Storage Account details
18+
$storageAccountName = backup_$random
19+
$containerName = "backups"
20+
$backupName = $apimServiceName + ".apimbackup"
21+
22+
# Select into the ResourceGroup
23+
Select-AzureRmSubscription -SubscriptionId $subscriptionId
24+
25+
# Create a Resource Group
26+
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location -Force
27+
28+
# Create storage account
29+
New-AzureRmStorageAccount -StorageAccountName $storageAccountName -Location $location -ResourceGroupName $resourceGroupName -Type Standard_LRS
30+
$storageKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -StorageAccountName $storageAccountName)[0].Value
31+
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageKey
32+
33+
# Create API Management service
34+
New-AzureRmApiManagement -ResourceGroupName $resourceGroupName -Location $location -Name $apiManagementName -Organization $organisation -AdminEmail $adminEmail
35+
36+
# Backup API Management service.
37+
Backup-AzureRmApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName -StorageContext $storageContext -TargetContainerName $containerName -TargetBlobName $backupName
38+
39+
# Restore API Management service
40+
Restore-AzureRmApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName -StorageContext $storageContext -SourceContainerName $containerName -SourceBlobName $backupName
41+
42+

api-management/import-api-and-add-to-product/import_an_api_and_add_to_product.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
##########################################################
22
# Script to import an API and add it to a Product in api Management
33
# Adding the Imported api to a product is necessary, so that it can be called by a subscription
4-
###########################################################
4+
###########################################################
55

66
$random = (New-Guid).ToString().Substring(0,8)
77

0 commit comments

Comments
 (0)