I am trying to upload image from UWP app via Azure IoT Hub, however I keep getting the same error over and over again.
Code that I am using is tested on regular C# Console App with .NET 4.6.2 and files are uploaded to Blob Storage without any issues.
Here is my project.json file:
{
"dependencies": {
"Microsoft.Azure.Devices.Client": "1.2.10",
"WindowsAzure.Storage": "8.1.1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.3"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
Exception is of type Microsoft.WindowsAzure.Storage.StorageException with error message:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
Code is as follows:
DeviceAuthenticationWithRegistrySymmetricKey key = new deviceAuthenticationWithRegistrySymmetricKey(deviceId, deviceKey);
deviceClient = DeviceClient.Create(iotHubUri, key, TransportType.Mqtt);
await deviceClient.UploadToBlobAsync(fileName, stream);
iotHubUri contains host name of IoT Hub in format HOST.azure-devices.net
deviceId is device identifier under which device was registered with IoT Hub
deviceKey is device identifier received during device registration with IoT Hub
I am using Visual Studio 2015 with Update 3.
Am I missing something?
Have you tried it with "WindowsAzure.Storage": "7.0.0" ?
@enesuysal Yes, tried it right now again, same thing.
Ok, I've managed to isolate what is the issue, although the message is entirely misleading.
If I attempt to upload file named "snapshot.jpg", it works well.
If I however attempt to upload file named "snapshot (2).jpg" error above is raised.
Direct uploads of file "snapshot (2).jpg" to Storage works without any issues - it is only when IoT Hub is used to proxy SAS that this error occurs.
Could it be that this extension to file name interferes with how is request formed to Storage by IoT Hub SDK?
Hello @atuzovic can you confirm that you can't upload a file named with spaces both on the UWP and C# Sdk samples?
Hello @atuzovic we identified the root cause of this issue and will deploy a fix. The SDK is encoding spaces with "+" and Azure Storage is expecting "%20". Thanks a lot for your contribution :)!
Thank you for your prompt response! :)
@atuzovic We have checked in the fix for this issue . Commit - 863f6b01f3a083ef485bfa543ddf40675f00b8c7. Next SDK nuget release will have these fixes .