This article explains how to add images to Azure blob storage containers using C# .NET Core. The Complete code can be downloaded from the 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.

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

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

ailogica azure helpers

Configuration

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

var azureHelper = new BlobHelpers("YourBlobStorageConnectionString");

Upload Images to blob Storage

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

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

Check if a specific Image is already in Azure Blob Container.

var azureHelper = new BlobHelpers("YourBlobStorageConnectionString");
bool isExist = azureHelper.BlobExist("ContainerName", "FileName", "FilePath");

The next articles of this series will explain

Categorized in:

Tagged in: