Created
December 13, 2017 16:35
-
-
Save esell/4d9c3a25ec59e281ca753974daab281d to your computer and use it in GitHub Desktop.
Backup a blob from one sa to another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Output "PowerShell Timer trigger function executed at:$(get-date)"; | |
# Create src/dest contexts | |
# DEST_KEY & SRC_KEY are set as environment variables in app settings | |
$DestContext = New-AzureStorageContext -StorageAccountName "destStorageAccountName" -StorageAccountKey $env:DEST_KEY | |
$SrcContext = New-AzureStorageContext -StorageAccountName "srcStorageAccountName" -StorageAccountKey $env:SRC_KEY | |
# Get timestamp | |
$timestamp = Get-Date -Format o | foreach {$_ -replace ":", "."} | |
# Set dest filename | |
$destFilename = "destFilename" + $timestamp | |
# Copy blob | |
Start-AzureStorageBlobCopy -SrcBlob "srcFilename" -SrcContainer "copyFrom" -DestContainer "copyto" -DestBlob $destFilename -SrcContext $SrcContext -DestContext $DestContext | |
# List blobs in dest container | |
Get-AzureStorageBlob -Container "copyto" -Context $DestContext | select Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment