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

TestDeveloper12345 21 Reputation points
2022-04-18T07:22:33.913+00:00

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
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,415 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sumarigo-MSFT 43,406 Reputation points Microsoft Employee
    2022-04-22T08:24:34.267+00:00

    @TestDeveloper12345 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://learn.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.

    0 comments No comments

  2. Jamil Hallal 21 Reputation points
    2022-05-05T09:52:45.567+00:00

    Hi @TestDeveloper12345 ,
    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.  
            }  
    
    0 comments No comments