Can a previous version of an Azure Storage Blob, with blob versioning enabled, be downloaded using Powershell or Azure CLI (or other) ?
In the Azure Portal, with Blob versioning enabled, you can download the previous versions, as in the image below:
Downloading previous version from Azure portal
Using Powershell, I can retrieve/download a list of previous versions with the Get-AZStorageBlob -IncludeVersion paramater
PS W:\SRE\KeyVaultBackupPOC> $blob = Get-AzStorageBlob -Container blobversiontest -Context $StorageContext -IncludeVersion
PS W:\SRE\KeyVaultBackupPOC> $blob
AccountName: blobstorage, ContainerName: blobversiontest
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted VersionId
---- -------- ------ ----------- ------------ ---------- ------------ --------- ---------
BlobVersionTestFile… BlockBlob 26 text/plain 2021-03-12 03:44:16Z Hot False 2021-03-12T03:44:16.4786504Z
BlobVersionTestFile… BlockBlob 25 text/plain 2021-03-12 03:44:36Z Hot False 2021-03-12T03:44:36.8181879Z
BlobVersionTestFile… BlockBlob 24 text/plain 2021-03-12 03:44:57Z Hot False 2021-03-12T03:44:57.4459306Z *
However, I cannot find a way to retrieve the previous version, via script.
I can retrieve an ICloud blob object for the current version of the blob using Get-AzStorageBlob and the ICloudBlob property of the result, but if I try a similar method for a previous version of the blob, I get an error:
Get-AzStorageBlobContent: Object 'CloudBlob' cannot be null. (Parameter 'CloudBlob')
Hoping for some new insights - thanks in advance.