Manage Blob Storage Using MVC Web Application

Introduction

This article will cover the following:

  • Prerequisites
  • Implementation – Create a simple web application and install “Azure Storage” package
  • Implementation – Manage blob storage using the web application

Prerequisites

Implementation – Create a simple web application and install “Azure Storage” package using VS

Steps to be followed.

  • Open VS 2017, click on New Project, and choose Web application.
  • Choose an empty template with the MVC option only and click OK.
  • Create a Home Controller with the default methods.
  • Add a View named as “Index” and have a default template placed there.
  • Install packages like “Windows Azure Storage” to get this going.

Implementation – Manage blob storage using the web application

Steps to be followed.

  • Write the sample code to store the image into Blob container. For that, first extract the storage account name and the key to access the blob storages.
  • Code to store an image into the Blob container with the public URL.
  • Write the sample text in Index.cshtml file.
  • Run the application and check the storage account’s Blob container where the new upload will be.
  • Copy the path of the new image and paste in the browser to check if the correct image is being uploaded. As soon as we do it, it comes up to save the image.

Please find the attached zip file for project reference.

Happy learning!