4
任何人都可以告訴我如何從Azure Blob存儲中讀取文本文件嗎?如何連接Azure存儲以從Blob存儲讀取.txt文件
任何人都可以告訴我如何從Azure Blob存儲中讀取文本文件嗎?如何連接Azure存儲以從Blob存儲讀取.txt文件
這是很容易:
string text = CloudStorageAccount.Parse("<your connection string>").CreateCloudBlobClient().GetBlobReference("path/to/the/blob.txt").DownloadText();
當然,如果斑在一個公開的容器,你可以這樣做:
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();
我沒有訪問'GetBlobReference( 「String」)'而不是'我有'GetBlobReferenceFromServer()'我忘記了什麼? – jdave 2016-04-21 16:29:11
這個答案是從2010年開始的。如果方法名稱在中間年份發生了變化,我不會感到驚訝。 – smarx 2016-04-21 16:55:00