1

I'm working on a script to list the blobs in a container which has a ridiculous number of blobs (over 30 million!).

Anyway, I'm using the code from https://learn.microsoft.com/en-us/powershell/module/az.storage/get-azstorageblob?view=azps-3.8.0

Which appears to use a continuation token for every 10,000 files.

$MaxReturn = 10000
$ContainerName = "abc"
$Total = 0
$Token = $Null
do
 {
     $Blobs = Get-AzStorageBlob -Container $ContainerName -MaxCount $MaxReturn  -ContinuationToken $Token
     $Total += $Blobs.Count
     if($Blobs.Length -le 0) { Break;}
     $Token = $Blobs[$blobs.Count -1].ContinuationToken;
 }
 While ($Token -ne $Null)
Echo "Total $Total blobs in container $ContainerName"

The problem is that this always ends up hanging or getting stuck and never completes.

It usually gets around half way and I have to restart it which kicks off the entire process all over again.

However, I already have the data from the first run, is there a way to get it to start from a specific value rather than from the start?

Lets say I already have the records I need for the first 3 million blobs. How do I tell it to start from 3 million instead of 0?

Or am I not understanding how the process works?

5
  • 2 Questions: 1) Are you storing the continuation token somewhere and 2) Is your data static i.e. blobs are not being added or deleted from your blob container? Commented May 12, 2020 at 5:59
  • I am not storing the continuation token, but I could. Are you suggesting I could use the last token (before it hangs) to continue? And the data in the container is static. Commented May 12, 2020 at 6:04
  • 1
    @amaru96a Since the data in the container is static, you can store the latest ContinuationToken. Then run the script with the ContinuationToken next time to get remaining blobs。 Commented May 12, 2020 at 7:51
  • Thanks for the suggestion, will try it out and report back. Commented May 12, 2020 at 23:39
  • Thanks Jim that seems to work. Commented May 14, 2020 at 7:16

1 Answer 1

1

Just a summary for the issue to let others know who has the similar issue.

How do I tell it to start from 3 million instead of 0?

Since the data in the container is static, you can store the latest ContinuationToken. Then run the script with the ContinuationToken next time to get remaining blobs.

For more details you could refer to this article.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.