Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to retrieve blob data from Azure blob in Json format?

I have stored json data format in azure blob storage, Now want to retrieve that data from azure blob in the form of json.

I tried like following

 //get all blob from contrainer
            var storageAccount = CloudStorageAccount.Parse("connection string");
            var blobClient = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer container = blobClient.GetContainerReference("tablesblob");

            foreach (IListBlobItem item in container.ListBlobs(null, false))
            {
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    CloudBlockBlob blob = (CloudBlockBlob)item;
                    var ms = new MemoryStream();
                    //blob.DownloadToStream(ms); how to get blob data in the form of JSON?
                }
            }

how to get azure blob data in the form of JSON?

like image 786
Neo Avatar asked May 15 '15 10:05

Neo


People also ask

Can JSON be stored as blob?

You can store JSON data in Oracle Database using columns whose data types are VARCHAR2 , CLOB , or BLOB .

Where does Azure store JSON files?

Azure Table Storage is a key/value pair store (much like Amazon DynamoDB). With the latest changes to storage service announced yesterday, you can work with JSON objects and save them as key/value pair in Azure table storage.


1 Answers

You could try CloudBlockBlob.DownloadText method to download the blob contents as text and then use Json.Net's JsonConvert to serialize the string into your customer object. For example, something like the following:

            var customerData = blob.DownloadText();
            var customer = JsonConvert.DeserializeObject<Customer>(customerData);
like image 182
Gaurav Mantri Avatar answered Sep 22 '22 00:09

Gaurav Mantri