We are storing the application logs in Azure BLOB
storage. We are currently downloading the files using the complete URI to the file. Every time when the settings of Azure BLOB
is changed, the file name also gets changed. So we are getting error as file not exists.
Suggest a way to get the files using file extension from a directory without having file name in UI.
Use the ListBlobs()
method to retrieve all blobs for a specific container and then you could use the static .NET Path.GetExtension()
method to retrieve the file extension so you can filter them. Example:
var storageAccount = CloudStorageAccount.Parse("yourCS");
var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(container);
var list = container.ListBlobs();
var blobs = list.OfType<CloudBlockBlob>()
.Where(b => Path.GetExtension(b.Name).Equals("yourextension"))