Created
April 28, 2015 08:57
-
-
Save pkirch/29f5dc62fcdd640d8627 to your computer and use it in GitHub Desktop.
Create a snapshot of an Azure BLOB via PowerShell.
This file contains 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
# step 1: get file | |
$blobFile = Get-AzureStorageBlob -Container source | Where-Object -Property Name -eq "version.txt" | |
# step 2: create snapshot | |
$cloudBlob = $blobFile.ICloudBlob | |
$cloudBlob.CreateSnapshot() | |
# step 3: get snapshots | |
$snapshot = Get-AzureStorageBlob -Container source | Where-Object -Property SnapshotTime | |
# step 4: download snapshot | |
$snapshot[0] | Get-AzureStorageBlobContent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example using AZ commands to pull all containers and blobs in a storage account and take a snapshot. The 3rd line with -eq $null filters out the existing snapshots, since a snapshot cannot be taken of another snapshot.
$blobstest = Get-AzStorageAccount | Where-Object -property StorageAccountName -eq 'storageaccountname' | Get-AzStorageContainer | Get-AzStorageBlob
$cloudBlob = $blobstest.ICloudBlob | Where-Object -property SnapshotTime -eq $null
$cloudBlob.CreateSnapshot()