Code Monkey home page Code Monkey logo

Comments (8)

asergaz avatar asergaz commented on July 20, 2024

Hi @arturl . See the changes here for enabling UploadToBlobAsync in UWP:
9983d01

This is going into the master branch soon.
Thanks!

from azure-iot-sdk-csharp.

pandazzurro avatar pandazzurro commented on July 20, 2024

I try this solution but I have this error:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

from azure-iot-sdk-csharp.

asergaz avatar asergaz commented on July 20, 2024

Hello @pandazzurro,
Thanks for trying it. Are you trying my branch or the master one? This isn't on the master branch nor nugget package yet.

If you are using my branch can you detail a bit more what is the line and class it is failing?

Thanks

from azure-iot-sdk-csharp.

pandazzurro avatar pandazzurro commented on July 20, 2024

Hi @sergaz-msft,
I commit project:
https://github.com/pandazzurro/IoTHubUWP
I use your branch.

        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();
            try
            {
                string myConnectionDevice = "myconn";
                DeviceClient client = DeviceClient.CreateFromConnectionString(myConnectionDevice);
                MemoryStream stream = new MemoryStream();
                StreamWriter writer = new StreamWriter(stream);
                writer.Write("CiaoSonoUnMessaggio");
                writer.Flush();
                stream.Position = 0;
                await client.UploadToBlobAsync("demo", stream);
            }
            catch (Exception ex)
            {
                var a = ex;
            }
        }

await client.UploadToBlobAsync("demo", stream); break
Thanks

from azure-iot-sdk-csharp.

asergaz avatar asergaz commented on July 20, 2024

Hi @pandazzurro ,
Instead of creating the stream can you try using it like on our sample?

public async Task UploadFile(Windows.Storage.StorageFile file)
        {
                var fileName = file.Name;
                using (Windows.Storage.Streams.IRandomAccessStreamWithContentType stream = await file.OpenReadAsync())
                await deviceClient.UploadToBlobAsync(fileName, stream.AsStream());
        }

You need to use Windows.Storage.Streams since this is a UWP app.

Also you can now use the master branch, that already has the changes.
5357642

from azure-iot-sdk-csharp.

pandazzurro avatar pandazzurro commented on July 20, 2024

Hi @sergaz-msft,
I updated my project with master dll file.
I have created one project with IoT template and one project with UWP template.

I have same error.

 Task.Run(async () =>
                {
                    string myConnectionDevice = "HostName=gabp2017.azure-devices.net;DeviceId=TestDevice;SharedAccessKey=blablabla=";
                    DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(myConnectionDevice);

                    StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Images/GAB.png"));
                    var fileName = file.Name;
                    using (Windows.Storage.Streams.IRandomAccessStreamWithContentType stream = await file.OpenReadAsync())
                        await deviceClient.UploadToBlobAsync(fileName, stream.AsStream());
                }).Wait();

Do you think that the error is the connectionString?

Thanks

from azure-iot-sdk-csharp.

pandazzurro avatar pandazzurro commented on July 20, 2024

Hi @sergaz-msft,
Now work for me.
I must unlink blob account from IoTHub, then I link it again.

ConnectionString is the same but now it work!
Great! 👍
Good Job!

You save my session in Global Azure Bootcamp

from azure-iot-sdk-csharp.

asergaz avatar asergaz commented on July 20, 2024

Glad that you made it @pandazzurro :). You shouldn't need to relink the Azure Blob in the Portal unless it had a TTL.

Good luck with the Global Azure Bootcamp :).

All Best

from azure-iot-sdk-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.