Query a deleted blob

Shlomi 1 Reputation point
2021-05-24T11:41:19.513+00:00

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
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. shiva patpi 13,376 Reputation points Microsoft Employee Moderator
    2021-05-25T06:20:48.967+00:00

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

    https://learn.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://learn.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.


  2. shiva patpi 13,376 Reputation points Microsoft Employee Moderator
    2021-05-27T00:56:19.48+00:00

    Hello @Shlomi ,
    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 !


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.