When we use the method listBlobContainers
to list containers, It will paginate if its number is greater than 5000. We also can use ListBlobContainersOptions
to define per page size. For more details, please refer to here and here
for example
String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName);
StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey);
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildClient();
ListBlobContainersOptions options = new ListBlobContainersOptions();
options.setMaxResultsPerPage(5);
PagedIterable<BlobContainerItem> pagedIterableResponse= blobServiceClient.listBlobContainers(options, null);
Iterator<PagedResponse<BlobContainerItem>> ite = pagedIterableResponse.iterableByPage().iterator();
int i =1;
while(ite.hasNext()){
PagedResponse<BlobContainerItem> items= ite.next();
System.out.println("The containers in the page "+i);
i++;
for (BlobContainerItem item: items.getValue()
) {
System.out.println("\t"+item.getName());
}
}
