question

Shlomi-7566 avatar image
0 Votes"
Shlomi-7566 asked Shlomi-7566 commented

Query a deleted blob

Hello,

We currently have only "versioning for blobs" enabled (we don't need soft delete).
I was wondering if there is any az cli query to list deleted blobs.
I know that when you delete a blob it becomes a previous version, but I am trying to find a way to search for deleted blobs from a particular container.
In the GUI, if you enable "Show deleted blobs" you can see a previously deleted blob with status "Deleted" - Is there any equivalent cli query to list blobs with status Deleted?

Thanks!


azure-blob-storage
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered Shlomi-7566 commented

Hello @Shlomi-7566 ,
Thanks for your query ! Did you try the azure power shell commands mentioned in the below article ?

https://docs.microsoft.com/en-us/powershell/module/az.storage/get-AzStorageblob?view=azps-5.9.0

Get-AzStorageContainer -Name container* | Get-AzStorageBlob -IncludeDeleted

Container Uri: https://storageaccountname.blob.core.windows.net/container1

Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted


test1 BlockBlob 403116 application/octet-stream 2017-11-08 07:53:19Z 2017-11-08 08:19:32Z True
test1 BlockBlob 403116 application/octet-stream 2017-11-08 09:00:29Z True
test2 BlockBlob 403116 application/octet-stream 2017-11-08 07:53:00Z False


You can also use az cli command
https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az_storage_blob_list

az storage blob list -c mycontainer --prefix foo --include deleted


Customize the above commands accordingly to list only deleted ones.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hey Shivapatpi,

Thanks for your replay.
As mentioned in my original post - we do not use "soft delete" data protection, so using a query with --include d will come out empty.
Only when using --include v I can see the previous versions of the deleted blob.
My question is - If it is possible to see blobs with status "deleted" even though "soft delete" protection is not enabled, only versioning.
In the GUI for instance, if you toggle the "show deleted blobs" you can see those deleted files with status deleted (and again, soft delete is not enabled).
So how come it is not possible with the az cli?

99807-screen-shot-2021-05-26-at-122656.png


0 Votes 0 ·
shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered Shlomi-7566 commented

Hello @Shlomi-7566 ,
I just tested out with below scenario.
Created a storage account with "Enable versioning for blobs".
Deleted the blob from portal

Using below azure PowerShell command , I was able to see the deleted blobs with versions.

//get the storage account context
$sa = Get-AzStorageAccount -Name storageaccountname -ResourceGroupName resourcegroupname
//get the blobs
Get-AzStorageBlob -Context $sa.Context -Container test -includeversion -IncludeDeleted


AccountName: testblobversion, ContainerName: test

Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted VersionId


test.txt BlockBlob 88494 text/plain 2021-05-27 00:47:42Z Hot False 2021-05-27T00:47:42.2346572Z
test.txt BlockBlob 88494 text/plain 2021-05-27 00:47:48Z Hot False 2021-05-27T00:47:48.4078468Z
test.txt BlockBlob 88494 text/plain 2021-05-27 00:47:52Z Hot False 2021-05-27T00:47:52.8548646Z
test.txt BlockBlob 88494 text/plain 2021-05-27 00:47:57Z Hot False 2021-05-27T00:47:57.6150960Z


Let me know if that helps out !

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hey shivapatpi,

Thanks again for you replay.

From your output, I do not see "IsDeleted True", so its the same "issue" I encountered.
If you will omit the "-includeversion" you will get no output.
As mentioned, I can see the previous versions of the deleted file, but there is no status = deleted for that blob.
Whereas, in the GUI (See my previous screenshot) when toggling "show deleted blobs" on, you see "Status = Deleted".
So how come there is no such field when using the az cli/PS?

0 Votes 0 ·

Hey @shivapatpi-MSFT,


Any thoughts regarding my comments?

Thanks.

0 Votes 0 ·