VB.net code read a csv content from blob

Posted by Rajnilari2015 under Azure category on | Points: 40 | Views : 99
The below code will do so

Public Function GetBlobData(filename As String, connectionString As String, containerName As String) As String
' Retrieve storage account from connection string.
Dim storageAccount As CloudStorageAccount = CloudStorageAccount.Parse(connectionString)

' Create the blob client.
Dim blobClient As CloudBlobClient = storageAccount.CreateCloudBlobClient()

' Retrieve reference to a previously created container.
Dim container As CloudBlobContainer = blobClient.GetContainerReference(containerName)

' Retrieve reference to a blob named "test.csv"
Dim blockBlob2 As CloudBlockBlob = container.GetBlockBlobReference(filename)

Dim text As String
Using memoryStream = New MemoryStream()
text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray())
End Using

Return text
End Function

Comments or Responses

Login to post response