locked
cannot use C# console program connection Azure blob RRS feed

  • Question

  • My customer gave me SAS and asked me to upload the file to his Azure server's Bolb container.

    I successfully uploaded it with winform, but could not upload it with the console. It's all the same code.

    What's the problem, How can I upload in the console?

    Tuesday, April 28, 2020 7:30 AM

All replies

  • My customer gave me SAS and asked me to upload the file to his Azure server's Bolb container.

    I successfully uploaded it with winform, but could not upload it with the console. It's all the same code.

    What's the problem, How can I upload in the console?



    Tuesday, April 28, 2020 7:26 AM
  • Hello, can we have a code sample ?

    Tuesday, April 28, 2020 9:48 AM
  • @nick-yao I assume SAS would been expired? Can you try to upload again using the code and check.

    Also let me know what happens when you try to upload using console? "Can you please elaborate what console are you referring too? 

    Can you share the code?

    Wednesday, April 29, 2020 4:24 AM
  •  public static class Program
        {
            static void Main(string[] args)
            {
                //GetfileAndUpload();
                testupload();
            }

            private async static void testupload()
            {
                var sas = @"https://swelementexternal.blob.core.windows.net/csv/20200428_test.csv?......";
                var cloudBlockBlob = new CloudBlockBlob(new Uri(sas));

                await cloudBlockBlob.UploadFromFileAsync(@"D:\9802Certificate\20200428_test.csv");
            }

    }

    Wednesday, April 29, 2020 9:19 AM
  • That's because you don't wait the end of the upload (await keyword). The testupload method should return a Task instead of void. In your Main you should then make something like

    testupload().GetAwaiter().GetResult();

    Saturday, May 2, 2020 5:05 PM
  • Is there any update on the issue?

    If the suggested answer helped for your issue, do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Wednesday, May 6, 2020 3:41 PM
  • Is there any update on the issue?

    If the suggested answer helped for your issue, do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Thursday, May 14, 2020 7:46 AM