1
votes

Is it possible to create an Azure Resource Manager template that sets up the automated backup of a Web App in Azure App Service?

I have everything else for the web sites set up through ARM, but I am stumped on getting automatic backup set up.

I have dug up the documentation for setting it through the REST Api
https://azure.microsoft.com/en-us/documentation/articles/websites-csm-backup/

So currently I can see two options.

Scripting the above REST api calls:
This I can of course script my way out of, but I would really like to do it through an arm template.

Manual through the portal:
This is not really feasible in any kind of automatic repeatable way.

Would really prefer an ARM solution.

1
Scripting REST api calls is not that straightforward. Azure starts complaining about apiVersion and Authorization token, which are not described. Have you found a way around?Sparrow_ua
No I haven't had the time to look into this sadlyRasmus

1 Answers

0
votes

No you cannot, but you can use PowerShell to do so.

UPDATE: Unfortunately the resources are not available in the docs anymore. I am using the Edit-AzureRmWebAppBackupConfiguration command like this:

$resourceGroupName = "backup"
$storageAccountName = "abc"
$blobContainerName = "def"
$startDate = (Get-Date).Date.AddMinutes(45).AddDays(1) # when should the first backup be triggered

$storageKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageName
$storageContext = New-AzureStorageContext -StorageAccountName $storageName -StorageAccountKey $storageKeys[1].Value
$sasToken = New-AzureStorageContainerSASToken -Name $blobContainerName -Permission rwdl -Context $context -FullUri -ExpiryTime ([DateTime]::MaxValue)
Edit-AzureRmWebAppBackupConfiguration -Name $appName -ResourceGroupName $resourceGroupName `
        -StorageAccountUrl $sasToken -FrequencyInterval 1 -FrequencyUnit Day -RetentionPeriodInDays 7 `
        -KeepAtLeastOneBackup -StartTime $startDate