简体   繁体   中英

Azure Web App Backup through ARM

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM