locked
upload files on cloud storage RRS feed

  • Question

  • User-1053625857 posted

    Hi, i have website framework 4.6 and i want to upload imagefiles on azure storage.

    it' works using CloudStorageAccount storageAccount = CloudStorageAccount.Parse(" ....") etc
    use nuget package Microsoft.Azure.Storage.Blob, Microsoft.Azure.Storage.Common, but it marks deprecated pachage

    now i use 

    Azure.Storage.Blobs
    Azure.Storage.Common

    but CloudStorageAccount, CloudBlobClient not found.

    How can i resolve ?

    Monday, November 16, 2020 7:16 AM

Answers

  • User1686398519 posted

    Hi Trinita, 

    1. Microsoft.Azure.Storage.Blob is replaced by the following new Azure SDKs. The latest libraries that interact with Azure storage services are:
      1. Azure.Storage.Blobs
      2. Azure.Storage.Queues
      3. Azure.Storage.Files.Shares
    2. I found an example of Uploading a blob after installing Azure.Storage.Blobs, you can refer to this link.
      • string connectionString = "<connection_string>";
        string containerName = "sample-container";
        string blobName = "sample-blob";
        string filePath = "sample-file";
        // Get a reference to a container named "sample-container" and then create it
        BlobContainerClient container = new BlobContainerClient(connectionString, containerName);
        container.Create();
        // Get a reference to a blob named "sample-file" in a container named "sample-container"
        BlobClient blob = container.GetBlobClient(blobName);
        // Upload local file
        blob.Upload(filePath);

    Best Regards,

    YihuiSun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 17, 2020 6:48 AM

All replies

  • User1686398519 posted

    Hi Trinita, 

    1. Microsoft.Azure.Storage.Blob is replaced by the following new Azure SDKs. The latest libraries that interact with Azure storage services are:
      1. Azure.Storage.Blobs
      2. Azure.Storage.Queues
      3. Azure.Storage.Files.Shares
    2. I found an example of Uploading a blob after installing Azure.Storage.Blobs, you can refer to this link.
      • string connectionString = "<connection_string>";
        string containerName = "sample-container";
        string blobName = "sample-blob";
        string filePath = "sample-file";
        // Get a reference to a container named "sample-container" and then create it
        BlobContainerClient container = new BlobContainerClient(connectionString, containerName);
        container.Create();
        // Get a reference to a blob named "sample-file" in a container named "sample-container"
        BlobClient blob = container.GetBlobClient(blobName);
        // Upload local file
        blob.Upload(filePath);

    Best Regards,

    YihuiSun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 17, 2020 6:48 AM
  • User-1053625857 posted

    thank's Yihui,

    i try this and it works

    BlobContainerClient container = new BlobContainerClient("AzureBlobStorageAccount", "ContainerFolder");
               
    BlobClient blob = container.GetBlobClient(folder + "/" +fileName);

    stream.Position = 0;   // important
    await blob.UploadAsync(stream, true);

    Tuesday, November 17, 2020 7:26 AM