azure blob storage

Add images to Azure blob storage in .NET Core

This article explains how to add images to Azure blob storage container using C# .NET Core. The Complete code can be downloaded from following GitHub repository

  • Nuget Url:¬†https://www.nuget.org/ packages /ailogica.Azure.Helpers/
  • Source Code: https://github.com/ nulhaq /Azure-Helpers

Before starting please make sure you have already created azure storage account and already added a blob container.

Installation and configuration.

First step is to install “ailogica.Azure.Helpers” NuGet package. This package contains lot of helpers to work with Microsoft Azure. 

When you install “ailogica.Azure.Helpers” NuGet package there are other NuGet package installed as part of installation. One notable page is “WindowsAzure.Storage” NuGet package. This package is Microsoft Azure storage SDK from Microsoft. This SKD helps us to perform different operations such as Create, Read, Update, Delete for Blobs, File storage and also helps us to manage queues.

ailogica azure helpers

Configuration

You need to add Azure blob storage Connection string in App.Config or Web.Config and you need to pass this connection string to BlobHelpers while instantiating object. 

var azureHelper = new BlobHelpers("YourBlobStorageConnectionString");

Upload Images to blob Storage

Following code 2 liner snippet will help you to add images in blob container of your choice

var azureHelper = new BlobHelpers("YourBlobStorageConnectionString");
var uploadBlobs = azureHelper.UploadBlobs("ContainerName", "FileName", "FilePath");

Check if specific Image is already in Azure Blob Container.

var azureHelper = new BlobHelpers("YourBlobStorageConnectionString");

bool isExist = azureHelper.BlobExist("ContainerName", "FileName", "FilePath");

Next articles of this series will explain

  • List Images from Azure Blob Storage Container.
  • Get Images from Azure Blob Storage Container.
  • Download images from Azure Blob Storage Container.

About the author

Naveed Ul-Haq

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *