簡體   English   中英

如何連接Azure存儲以從blob存儲中讀取.txt文件

[英]How to connect Azure Storage to read .txt files from blob storage

任何人都可以讓我知道如何從Azure Blob存儲中讀取文本文件?

這很簡單:

string text = CloudStorageAccount.Parse("<your connection string>").CreateCloudBlobClient().GetBlobReference("path/to/the/blob.txt").DownloadText();

當然,如果blob在公共容器中,您可以這樣做:

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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM