Skip to content

Commit

Permalink
added backup script (Azure#94)
Browse files Browse the repository at this point in the history
* added backup script

* moved a file
  • Loading branch information
Juliako authored and erickson-doug committed Oct 30, 2017
1 parent 44829e9 commit aecd9ce
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##########################################################
# Script to backup and restore api management service.
###########################################################

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

#Azure specific details
$subscriptionId = "my-azure-subscription-id"

# Api Management service specific details
$apimServiceName = "apim-$random"
$resourceGroupName = "apim-rg-$random"
$location = "Japan East"
$organisation = "Contoso"
$adminEmail = "admin@contoso.com"

# Storage Account details
$storageAccountName = backup_$random
$containerName = "backups"
$backupName = $apimServiceName + ".apimbackup"

# Select into the ResourceGroup
Select-AzureRmSubscription -SubscriptionId $subscriptionId

# Create a Resource Group
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location -Force

# Create storage account
New-AzureRmStorageAccount -StorageAccountName $storageAccountName -Location $location -ResourceGroupName $resourceGroupName -Type Standard_LRS
$storageKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -StorageAccountName $storageAccountName)[0].Value
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageKey

# Create API Management service
New-AzureRmApiManagement -ResourceGroupName $resourceGroupName -Location $location -Name $apiManagementName -Organization $organisation -AdminEmail $adminEmail

# Backup API Management service.
Backup-AzureRmApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName -StorageContext $storageContext -TargetContainerName $containerName -TargetBlobName $backupName

# Restore API Management service
Restore-AzureRmApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName -StorageContext $storageContext -SourceContainerName $containerName -SourceBlobName $backupName


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

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

Expand Down

0 comments on commit aecd9ce

Please sign in to comment.