Could anyone let me know how to read a text file from Azure Blob Storage?
Go to Container from the portal and select the particular file to get the link to access. Copy the link and paste in the Browser. Here are your files. Hence, from the steps shown above, you can create Storage account, Container, store and access the files from the portal.
Open the File Selector dialog from the Message Analyzer File menu by highlighting Open and then selecting the From Other File Sources command. In the Add Azure Storage Connection dialog, specify Account name and Account key information, as described in Accessing Log Data in Azure Storage BLOB Containers.
Open a blob on your local computer Select the blob you wish to open. On the main pane's toolbar, select Open. The blob will be downloaded and opened using the application associated with the blob's underlying file type.
Under the search box, select Built-in. In the search box, enter Azure blob. From the Triggers list, select the built-in trigger named When a blob is Added or Modified in Azure Storage. If you're prompted for connection details, create a connection to your Azure Storage account.
It's pretty easy:
string text = CloudStorageAccount.Parse("<your connection string>").CreateCloudBlobClient().GetBlobReference("path/to/the/blob.txt").DownloadText();
Of course, if the blob is in a public container, you can just do:
string text = new WebClient().DownloadString("http://youraccount.blob.core.windows.net/path/to/blob.txt");
// connect to development storage. To connect to azure storage use connection string
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudBlobClient client = storageAccount.CreateCloudBlobClient();
// if you know the blob you want to access you can do this:
CloudBlob blob = client.GetBlobReference("containername/blobname.txt");
// To display text in console:
Console.WriteLine(blob.DownloadText());
Console.ReadKey();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With