Azure Storage Library Client on Windows 10 Iot/UWP?
Asked Answered
A

1

2

It appears that the Azure Storage Client is not supported on Windows 10 Iot-Core/UWP (RPi). However, I am using it for Blobs, and it also used to work fine for Tables. Now, after an update to the latest stable (and -pre, tried both) the access to Tables hangs at

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

I searched in vain for a way to make this synchronous, which would, at the least, help me debug it. I also am wondering about the current success of others and the "scoop" on using the Azure Storage Client on IoT-Core (RPi).

UPDATE: Extended the RequestOptions as below and my simple call also shown below. I double checked the connection string, the table access (from other tools) and the account. All of them work fine from other places. I've also pasted the exceptions I get in VStudio2015 remote debugging to IoT-Core RaspberryPi latest version.

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

Exceptions: Any ideas or modifications to my test code?

{"<?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>"}
Allineallis answered 4/1, 2016 at 15:44 Comment(5)
First, you can always use the REST API - the client library is just a wrapper around it. Second, why do you think making something "synchronous" will make it easier to debug instead of harder? await ... doesn't do any magic, it awaits an already asynchronous operation. And HTTP calls are asynchronous even on the desktop - it's actually an OS trick that makes them appear synchronous. Have you tried wrapping your code in a try/catch block and logging the exception? How long did you wait for the call to return? What timeout value did you use?Mediocre
Thanks. Yes, I already use the REST API for the Service Bus on IoT-core, it s just simpler with the client lib. Yes, have a try/catch. The call simply hangs, never returns, and never throws an exception on the IoT-core ARM platform. I have turned on everything in sight, including CLR exceptions. Just hangs. Can't explain it since it was working...Allineallis
The request may be taking too long, or result in too many retries. Have you tried passing a TableRequestOptions object with the MaximumExecutionTime or ServerTimeout set?Mediocre
Updated the question with test code and the returned exception (VisualStudio 2015 remote debugger). Any ideas appreciated. Since I use this storage lib to manage blobs in the same IoT-core App, I'd still like to leverage it (and not REST) for my tables.Allineallis
Appears to be the same issue: #32364406Allineallis
A
0

Yes, unfortunately UWP apps are not supported yet by Storage, as there's a bug in the UWP platform that causes problems with Auth. We are waiting on a fix from the UWP team. Thanks!

Azine answered 19/1, 2016 at 18:23 Comment(1)
Please let us know on this channel. Thanks!Allineallis

© 2022 - 2024 — McMap. All rights reserved.