Home > Back-end >  How to determine if an Azure StorageV2 (Data Lake Storage with Hierarchical namespace) BlobItem is a
How to determine if an Azure StorageV2 (Data Lake Storage with Hierarchical namespace) BlobItem is a

Time:07-20

I have the following code:

var client = new BlobServiceClient("connection string");
var container = client.GetBlobContainerClient("my-container");
await foreach(var item in container.GetBlobsAsync()) {
   // do something about the item if it is a file
}

I found that there is no way to determine if the item is a virtual directory or a file. I had also tried client.GetBlobsByHierarchyAsync, the folder still shows up as a BlobItem not a Prefix. What am I missing here?

** Edit for clarification.
I am using Azure Storage Account blob containers. There are other past similar posts and the answers suggested as well that directory is not supported in ABS. But Azure moves at a pretty fast pace. Please see that attached screenshot. They sure looks like directories to me.

** Edit for further clarification. It seems that there are two "Kinds" of storage account. In the Storage accounts UI, they are indicated as either "Storage" or "StorageV2". StorageV2 has Hierarchical namespace = enabled under "Data Lake Storage" properties. I will updated the title accordingly.

enter image description here

CodePudding user response:

ADLS GEN 2 accounts (V2 Storage accounts with hierarchical namespace enabled) are built on top of blob storage. What that means is that some of the features available in blob storage are available for ADLS GEN2 accounts as well.

For most parts, you can use Azure.Storage.Blobs SDK for managing the data in your ADLS GEN2 accounts.

However there are some additional features which are only available in ADLS GEN2 accounts (e.g. first class support for folder hierarchy, POSIX support etc.). In order to take advantage of these additional features and manage them, you would want to use Azure.Storage.Files.DataLake SDK instead of Azure.Storage.Blobs.

  • Related