Working with Storage Blobs
Tags: azureapril, devtips, storage, webdev
Published: 2019-04-06 15:45:06

---
title: Working with Storage Blobs
published: true
description: 
tags: azureapril, devtips, storage, webdev
series: Azure April
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pblyvmtj4y8bdqisyzey.jpeg
---

*We've selected our favorite tips and tricks created by [Michael Crump](https://twitter.com/mbcrump) and are delivering fresh technical content on Azure all April! Miss a day (or more)? [Catch up with the series](https://dev.to/t/azureapril).*

**Don't have Azure?** [Grab a free subscription](https://azure.microsoft.com/en-us/free?&WT.mc_id=azureapril_devto-blog-cxa).  

----

[Azure Storage](https://docs.microsoft.com/en-us/azure/storage?&WT.mc_id=azureapril_devto-blog-cxa) is described as a service which provides storage that is available, secure, durable, scalable, and redundant. 

Azure Storage is an umbrella term. It covers:

* [Blob storage](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-overview?&WT.mc_id=azureapril_devto-blog-cxa)
* [Data Lake storage](https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction?&WT.mc_id=azureapril_devto-blog-cxa)
* [File storage](https://docs.microsoft.com/en-us/azure/storage/files/storage-files-introduction?&WT.mc_id=azureapril_devto-blog-cxa)
* [Queue storage](https://docs.microsoft.com/en-us/azure/storage/queues/storage-queues-introduction?&WT.mc_id=azureapril_devto-blog-cxa)
* [Table storage](https://docs.microsoft.com/en-us/azure/storage/tables/table-storage-overview?&WT.mc_id=azureapril_devto-blog-cxa)

We're going to focus on Blob storage for now. 

# Creating Blob Storage in the Azure Portal 📂

Go ahead and open the [Azure Portal](https://azure.microsoft.com/en-us/features/azure-portal/?&WT.mc_id=azureapril_devto-blog-cxa) and click `Create a Resource`. Select `Azure Storage`. We’ll keep it simple as shown below to get started.

![create](https://d33wubrfki0l68.cloudfront.net/b7645052be9c63c3640e848daba977ddf4a46e9f/058ec/files/storageacct1.png)

Once complete — the portal will notify you — go into the resource and look under `Services`.

![find it](https://d33wubrfki0l68.cloudfront.net/9284e1b624ffe72451a8b7ae5eedc0417b02b396/5b3be/files/storageacct2.png)

Go ahead and click on `Blobs` and create a `Container` and give it the name `Images`.

> Remember! A container is a lot like a folder. `https://myblob/container/image1.jpg`

You’ll now want to click `Upload` and select a file on your physical disk.

![upload](https://d33wubrfki0l68.cloudfront.net/6169cbd610f715c39319c0f24281f3c530711a68/53696/files/storageacct4.png)

Now that your file is uploaded, select it. You can click on the ellipsis and select `Blob properties` to see additional details.

![done](https://d33wubrfki0l68.cloudfront.net/b386bbc78a81a72061126042d3deda8cf4942d62/c11bc/files/storageacct5.png)

Yay! You can download it or access it via the URL provided. That was pretty easy, right?

Let's do the same thing... differently. 

# Provisioning an Azure Storage Blob Container in C# 🗄️

Yes, the code we're using is C# but don't freak out if you don't know C# (I don't!) Michael Crump wrote this code and I think it's clear what's happening — regardless of your language of choice. 

Navigate to your Azure Storage account in the portal.

Look under `Settings`, then `Access Keys` and copy the connection string.

![connection string](https://d33wubrfki0l68.cloudfront.net/748934007efa227bfcb9fbb6e8fe148be9211a3c/4d7d8/files/storagethroughcsharp1.png)

Create a C# Console Application, and use NuGet to pull in references to:

* WindowsAzure.Storage
* Microsoft.WindowsAzure.ConfigurationManager

![console application](https://d33wubrfki0l68.cloudfront.net/5f3c5e84c8a898d7633004c069b634042bba6c87/125ce/files/storagethroughcsharp3.png)

Inside of your Console app, you will see `App.config`, now add the following section:

```
<appSettings>
  <add key="StorageConnection" value="YOUR-CONNECTION-STRING-COPIED-FROM-EARLIER"/>
</appSettings>
```

Copy the following code into your Main method:

```
static void Main(string[] args)
{
    var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnection"));
    var myClient = storageAccount.CreateCloudBlobClient();
    var container = myClient.GetContainerReference("images-backup");
        
container.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
    Console.ReadLine();
}
```

This code will get our connection string from the `App.config`, create our client and a container named `images-backup` if it doesn’t exist. We can go back inside of the portal to see if executed correctly.

Success! We’ve now accomplished the same task via the Azure Portal and C#.

**Want more Azure Storage?** Check out our [quickstarts and tutorials]({{{LINK}}}?WT.mc_id=azureapril_devto-blog-cxa)!

---
We'll be posting articles every day in April, so stay tuned or jump ahead and check out more tips and tricks [now](http://azuredev.tips).