How to retrieve BLOB data from the Azure blob in the JBS format?

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

I tried to follow

//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))
{< br /> 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?

You can try to use the CloudBlockBlob.DownloadText method to download the blob content as text, and then use Json.Net’s JsonConvert to serialize the string to the client object For example, something like the following:

var customerData = blob.DownloadText();
var customer = JsonConvert.DeserializeObject(customerData) ;

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

< /p>

I tried to follow

//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))< br /> {
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
var ms = ne w 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?

You can try to use the CloudBlockBlob.DownloadText method to set the blob Download the content as text, and then use Json.Net’s JsonConvert to serialize the string into the customer object. For example, something like the following:

var customerData = blob. DownloadText();
var customer = JsonConvert.DeserializeObject(customerData);

Leave a Comment

Your email address will not be published.