Uploading Image to Azure Blob using File Uploader in ASP.NET? RRS feed

  • Question

  • I need to allow a user to specify an image that needs to be uploaded to the Azure DB instead of hard coding the Image Path like all the tutorials out there. This is what I have so far:

    <asp:FileUpload ID="imageUploader" runat="server" />
    <asp:Button ID="uploadBtn" runat="server" Text="Upload Image" class="btn btn-success btn-sm" OnClick="uploadBtn_Click" />


    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
     // Retrieve a reference to a container. 
    CloudBlobContainer container = blobClient.GetContainerReference("pictures");
    // Create the container if it doesn't already exist.
    container.SetPermissions(new BlobContainerPermissions
            PublicAccess = BlobContainerPublicAccessType.Blob
    CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
    blockBlob.UploadFromFile(imageUploader.PostedFile.FileName, FileMode.Open);

    However this doesn't seem to work. How can I upload an image to azure using a File Uploader in ASP.NET?

    Sunday, February 22, 2015 12:25 PM


All replies