我有一段代碼(在UWP應用程序中)從Azure存儲中讀取blob。我可以連接,枚舉容器並找到blob,但是當我嘗試下載它時,出現異常:指定的blob不存在。指定的Blob不存在,使用DownloadToStreamAsync
使用Azure門戶,我可以瀏覽容器,看到blob,甚至可以交互式下載。我已經檢查過這個網址,並且它們匹配。 我在同一個容器中的其他文件夾中有其他blob,代碼將它們正確下載。
blob通過流分析作業自動創建,這與創建其他Blob的方式相同。
string csvText = null;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CONNECTION_STRING);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(CONTAINER_NAME);
OperationContext context = new OperationContext();
BlobRequestOptions options = new BlobRequestOptions();
string prefix = string.Format("{0}/{1:yyyy/MM/dd/HH}", ROOT_FOLDER, SAMPLE_DATE); // ex: telemetry/2016/12/31/22
var blobs = await container.ListBlobsSegmentedAsync(prefix, true, BlobListingDetails.All, null, null, options, context);
CloudBlockBlob item = blobs.Results.FirstOrDefault() as CloudBlockBlob; // <<<< I see the blob here.
using (var memoryStream = new MemoryStream())
{
await item.DownloadToStreamAsync(memoryStream); // <<<< The specified blob does not exist.
csvText = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
編輯:堆棧跟蹤:
Source Microsoft.WindowsAzure.Storage
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__c`1.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.<>c__DisplayClass11.<<DownloadRangeToStreamAsync>b__10>d__13.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at HomeControl.Views.Historical.<LoadData>d__7.MoveNext()
我試圖讓一個小提琴手痕跡,但使用它與一個UWP應用程序有問題。 有關如何解決此錯誤的任何建議?
由於
-John