c# - Windows 10 Iot/UWP 上的 Azure 存储库客户端?

标签 c# azure azure-storage azure-table-storage windows-10-iot-core

Windows 10 Iot-Core/UWP (RPi) 似乎不支持 Azure 存储客户端。不过,我将它用于 Blob,并且它对于表也可以正常工作。现在,更新到最新的稳定版本(以及-pre,尝试了两者)后,对表的访问挂起在

await table.ExecuteQuerySegmentedAsync(query, new TableContinuationToken());

我徒劳地寻找一种使其同步的方法,这至少可以帮助我调试它。我还想知道其他人当前的成功以及在 IoT-Core (RPi) 上使用 Azure 存储客户端的“独家报道”。

更新: 如下扩展了 RequestOptions,我的简单调用也如下所示。我仔细检查了连接字符串、表访问(来自其他工具)和帐户。他们在其他地方都工作得很好。我还将 VStudio2015 远程调试中遇到的异常粘贴到 IoT-Core RaspberryPi 最新版本中。

        // Setup the table container
        // connectString looks fine, works fine elsewhere: http for debug instead of https 
        var connectionString = @"DefaultEndpointsProtocol=http;AccountName=myaccount;AccountKey=EUybijab+WHATEVERDzYubKGADwjf/6k5IuoRVgPMMqMez0gb07/dfAv9Qj1/v7NkstGAygWNab07q6FhNBQ==";

        var cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
        CloudTableClient cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
        cloudTable = cloudTableClient.GetTableReference(appSettings.AzureStorageOeConfigTableName);
        //never returns var x = await cloudTable.CreateIfNotExistsAsync();

        // Simplest query to existing small table
        var pkey = "b8-27-eb-86-5d-4d";
        var rkey = "0000000013505717";
        var tstOp = TableOperation.Retrieve(pkey, rkey);
        var requestOptions = new TableRequestOptions
        {
            PayloadFormat = TablePayloadFormat.JsonFullMetadata,
            LocationMode = LocationMode.PrimaryThenSecondary,
            RetryPolicy = new ExponentialRetry(),
            ServerTimeout = TimeSpan.FromMinutes(2)
        };
        // Throws exceptions shown below.
        var tst1 = await table.ExecuteAsync(tstOp, requestOptions, null);

异常(exception):对我的测试代码有什么想法或修改吗?

{"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<!--An exception has occurred. For more information please deserialize this message via RequestResult.TranslateFromExceptionMessage.-->\r\n<RequestResult>\r\n  <HTTPStatusCode>403</HTTPStatusCode>\r\n  <HttpStatusMessage>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.</HttpStatusMessage>\r\n  <TargetLocation>Primary</TargetLocation>\r\n  <ServiceRequestID>c4892c5a-0002-003a-4992-493991000000</ServiceRequestID>\r\n  <ContentMd5 />\r\n  <Etag />\r\n  <RequestDate>Wed, 06 Jan 2016 22:30:01 GMT</RequestDate>\r\n  <StartTime>Wed, 06 Jan 2016 21:29:55 GMT</StartTime>\r\n  <EndTime>Wed, 06 Jan 2016 21:32:12 GMT</EndTime>\r\n  <Error>\r\n    <Code>AuthenticationFailed</Code>\r\n    <Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\r\nRequestId:c4892c5a-0002-003a-4992-493991000000\r\nTime:2016-01-07T21:30:36.1204037Z</Message>\r\n  </Error>\r\n  <ExceptionInfo>\r\n    <Type>StorageException</Type>\r\n    <HResult>-2147467259</HResult>\r\n    <Message>Cannot access a closed Stream.</Message>\r\n    <Source />\r\n    <StackTrace />\r\n    <InnerExceptionInfo>\r\n      <ExceptionInfo>\r\n        <Type>ObjectDisposedException</Type>\r\n        <HResult>-2146232798</HResult>\r\n        <Message>Cannot access a closed Stream.</Message>\r\n        <Source>mscorlib</Source>\r\n        <StackTrace>   at System.IO.__Error.StreamIsClosed()\r\n   at System.IO.BufferedStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)\r\n   at System.Net.Http.DelegatingStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)\r\n   at Microsoft.WindowsAzure.Storage.Core.Util.StreamExtensions.&lt;WriteToAsync&gt;d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.&lt;ExecuteAsyncInternal&gt;d__c`1.MoveNext()</StackTrace>\r\n      </ExceptionInfo>\r\n    </InnerExceptionInfo>\r\n  </ExceptionInfo>\r\n</RequestResult>"}

最佳答案

是的,遗憾的是,存储尚不支持 UWP 应用,因为 UWP 平台中存在一个错误,会导致身份验证出现问题。我们正在等待 UWP 团队的修复。谢谢!

关于c# - Windows 10 Iot/UWP 上的 Azure 存储库客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34594757/

相关文章:

c# - 如何编写onrowcommand的事件

asp.net - 使用 LDAP 的 Active Directory 成员资格提供程序

c# - C#中使用HtmlAgilityPack解析网页信息

c# - 当应用程序以 xsession 启动时如何全屏显示 GTK# 窗口?

c# - 如何获取枚举值 ASP.NET MVC

SQL Azure : What will happen if size of my SQL Azure get 5GB?

linux - 如何使用PowerShell命令Get-AzMetric获取Azure Linux VM guest 指标?

azure - 我们可以使用带有 CCProj 的 Azure SDK 1.8 (Azure CCProj)

c# - container.ListBlobsSegmented 与 blobclient.ListBlobsWithPrefix 之间有什么区别?

azure - 使用 Windows Azure 查询表存储数据