Skip to content

Instantly share code, notes, and snippets.

@mathieu-benoit
Last active April 17, 2017 22:52
Show Gist options
  • Save mathieu-benoit/f3d6b1b2d330c4fe11dbf37b475745ec to your computer and use it in GitHub Desktop.
Save mathieu-benoit/f3d6b1b2d330c4fe11dbf37b475745ec to your computer and use it in GitHub Desktop.
Restore-WebApp-Backup-On-Slot
Param(
[string] [Parameter(Mandatory=$true)] $SubscriptionId,
[string] [Parameter(Mandatory=$true)] $ResourceGroupName,
[string] [Parameter(Mandatory=$true)] $WebAppName,
[string] [Parameter(Mandatory=$true)] $SlotName,
[string] [Parameter(Mandatory=$true)] $StorageAccountName,
[string] [Parameter(Mandatory=$true)] $ContainerName,
[string] [Parameter(Mandatory=$true)] $BlobFileName
)
Login-AzureRmAccount;
Select-AzureRmSubscription -SubscriptionId $SubscriptionId;
$storageAccountKey = Get-AzureRmStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName;
$context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $storageAccountKey[0].Value;
$sasUrl = New-AzureStorageContainerSASToken -Name $ContainerName -Permission rwdl -Context $context -ExpiryTime (Get-Date).AddDays(1) -FullUri;
Restore-AzureRmWebAppBackup -ResourceGroupName $ResourceGroupName -Name $WebAppName -Slot $SlotName -StorageAccountUrl $sasUrl -BlobName $BlobFileName -Overwrite;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment