Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Chandra Mohan Jha
Chandra Mohan Jha

Posted on

     

Get all blobs in given Azure container

In last article, we tried to download single blob file from azure storage usingAzure.Storage.Blobs. This is the new library developed byMicrosoft to replace depercatedMicrosoft.WindowsAzure.Storage. So let's get started.

0. Setting up the context

In this article, we will try to get all the blobs(images) stored on Azure blob storage in defined format i.e.User_id/image.ext.

john_doe/image1.jpgjohn_doe/profile.pngjane_doe/profile.PNG
Enter fullscreen modeExit fullscreen mode

So if there are blobs with given name in Azue, we are trying to get all blobs for user idjohn_doe

1. Install NuGet package

Install NuGet packageAzure.Storage.Blobs. At the time of writing this, the latest version is 12.8.0.

2. Import library

using Azure.Storage.Blobs;

3. Get connection string

I assume you have Azure account and thus connection string to connect to Azure Blob Storage. Store this in a variable or constant based on your need.

const string CONN_STRING = <connection_string_from_azure_portal>const string BLOB_CONTAINER = <blob_container_name>
Enter fullscreen modeExit fullscreen mode

-1. Now the final thing

I will list all blobs(images) present in given container and have specified format.

string userId = "john_doe";var allBlobs = container.GetBlobs(prefix: $"{userId}");
Enter fullscreen modeExit fullscreen mode

The above code will fetch all the blobs details present in container with given prefix(john_doe).

If you want to download the blobs as well,this article might be helpful.

That's it. I hope this will be helpful. 🙂

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromChandra Mohan Jha

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp