Skip to content

Instantly share code, notes, and snippets.

@pkirch
Created April 28, 2015 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkirch/29f5dc62fcdd640d8627 to your computer and use it in GitHub Desktop.
Save pkirch/29f5dc62fcdd640d8627 to your computer and use it in GitHub Desktop.
Create a snapshot of an Azure BLOB via PowerShell.
# 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
@jcbrooks92
Copy link

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment