I want to find if any file exists or not within my virtual directory inside my blob container . There is a possibility that there can be thousands of files inside it so I want to use the optimized approach . Also if the files exist I want to list those files .
My directory structure in container is Folder/Subfolder1/file.txt
Folder/Subfolder2/file.txt
So here I want to detect if there are files in Subfolder1 . Since azure storage has virtual directory structure Subfolder1 won’t exist in the absence of blobs . Hence I want to setup condition such that it finds if Subfolder1 exists and if yes list all files inside that.
Also is there any better way to get limited number of records from the GetBlobs(prefix: foldername) method , say if there are 500 files in my container and I want to list only 50 . Currently I am using a foreach loop and counter to list 50 files and break out of loop at count 50
var inputfiles = ContainerClient.GetBlobsAsync(prefix: inputfolder);
var count = 0;
List<string> FilesList = new List<string>();
await foreach (var blob in inputfiles)
{
count++;
if (count == 50)
break;
FilesList.Add(blob.Name);
}
I am using Azure SDK v12 and C# as language