question

TestDeveloper12345-7081 avatar image
0 Votes"
TestDeveloper12345-7081 asked jhallal edited

How to read data from azure blob storage in real time.

I want to develop an application in which data is in azure blob storage and after data processing i want to read that data in my application.

azure-blob-storage
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @TestDeveloper12345-7081

You can do it. There are many ways to do this, so knowing your information better will give you the right advice. Are you already hosting blob storage and applications on Azure?

0 Votes 0 ·

Yes,i have client whose sensors data are already stored on azure blob storage,now i want to know how to use this blob storage has a database and develop and deploy application on azure only.That application must get data from azure blob storage in real time. This whole project in on a fitness band which has sensors and that sensors are sending data to azure blob storage.Now i want to develop an application in which i am getting data from blob storage in real time and let band user know how much calories they burns or other things which i will calculate from data send by sensors.

0 Votes 0 ·
SumanthMarigowda-MSFT avatar image
0 Votes"
SumanthMarigowda-MSFT answered SumanthMarigowda-MSFT commented

@TestDeveloper12345-7081 If your application has to react to events much quicker than this, consider using Blob Storage events . Blob Storage Events provides real-time one-time events which enable your Azure Functions or applications to quickly react to changes that occur to a blob.

You can rely on the Blob Storage events and read the sensor data using function app. More Info here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=in-process%2Cextensionv5&pivots=programming-language-csharp


If you wants to use the Logic App then they can leverage this: https://techcommunity.microsoft.com/t5/azure-paas-blog/add-file-watcher-on-containers-in-azure-storage-account-using/ba-p/1301993

Please let us know if you have any further queries. I’m happy to assist you further.


Please do not forget to 195466-screenshot-2021-12-10-121802.pngand “up-vote” wherever the information provided helps you, this can be beneficial to other community members.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

jhallal avatar image
0 Votes"
jhallal answered jhallal edited

Hi @TestDeveloper12345-7081 ,
Here is a C# method to list all files in a blob container:

     public async Task ListAsync()
             {
                 // Get a connection string to our Azure Storage account.
                 string connectionString = ConnectionString;
        
                 // Get a reference to a container named "sample-container" and then create it
                 BlobContainerClient container = new BlobContainerClient(connectionString, Randomize("sample-container"));
                 await container.CreateAsync();
                 try
                 {   
                     // List all the blobs
                     List<string> names = new List<string>();
                     await foreach (BlobItem blob in container.GetBlobsAsync())
                     {
                         names.Add(blob.Name);
                     }
                 }
                 catch(Exception ex)
                 {
                     // Log the exception
                 }
             }

If you know the path of the file you want to download, then you can make use of the following method:

 public async Task DownloadImageAsync(string downloadPath)
         {
             // Download the public blob at https://aka.ms/bloburl
             await new BlobClient(new Uri("https://yourbloburl")).DownloadToAsync(downloadPath);
       
    
             byte[] fileBinary = File.ReadAllBytes(downloadPath)//you have the binary of the file so you can decide what to do with the file.
         }




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.