Exercise: Uploading an image into Azure Blob Storage

Natasha Ong
This is some text inside of a div block.
4 min read

Exercise Overview:

Welcome to this tutorial on how to use Azure Blob Storage. Today, we're going to explore how to store and manage your files in the cloud within Azure.

You will create your first storage blob (exciting 🤩) using these steps:

  1. Create a storage account
  2. Create containers
  3. Change the access level of your blob

Task 0: Where is Blob Storage in the Azure Portal?

  1. To get started, we'll need to log in to the Azure portal: https://portal.azure.com/#home
  2. Once you're in, navigate the page by looking for Create a resource button. This will lead us to a new page with all available resources in Azure.
  3. Click the Storage button in the left pane of the webpage (it's the second to last option).
  4. Click on Create under the Storage account heading.
  5. Handy tip: you can jump straight into the Storage accounts page by finding the shortcut on your home page - it's one of the icons next to the Create a resource button! Give this a try by going back to the home page, hover on the Storage accounts shortcut, and click on the Create button when a new rectangle about Storage accounts pops up.

Task 1: Create a storage account

Now, let's create an Azure Blob Storage account. Think of this as your own special spot in the cloud to store your files.

1. Leave the Subscription and Resource Group settings as it is by default. If you haven't made one before, find the prebuilt one from Azure which has the name 'learn'.

2. Give your storage account a unique name. Remember that the name should be unique across all existing Azure storage accounts.

In this example, use [your name]blobstorage. Note that everything has to be in lower case! For example, if your name is Darwin, you'd name your account darwinblobstorage.

3. Choose a region that's closest to you (like 'East US' or 'West Europe') or in this tutorial, let's use Asia Pacific Australia Central.

4. For now, let's go with 'Standard' - 'Locally redundant storage (LRS)' for redundancy.

Note: Though the default option is Geo-redundant, this exercise does not require yet a high level of data availability. Locally redundant storage is enough for everything we're doing in this activity. It's also the lowest cost option.

5. Let's now go to the Advanced tab.

6. Click on the checkbox next to Allow enabling anonymous access on individual containers. Leave the rest of the settings as default.

7. Select Review to review your storage account settings and allow Azure to validate the configuration. This should take less than 10 seconds.

8. Once validated, select Create. You'll see a "Deployment is in progress" page, and it'll take 2-3 minutes before your blob storage account is ready! When it's ready, your page will say "Your deployment is complete".

9. Select Go to resource.

Task 2: Work with a blob storage (Create containers and upload files)

Imagine containers as folders for your files. Let's create one to keep things organised.

Create a Container

  1. On the menu on the left hand side, look for the Data storage section and click on Containers.
  2. Hit the + container button on the top left hand side.
  3. Give your container a name. For example, [name]container.
  4. We'll leave the Anonymous access level as Private for now, but this will become important in the next step!

Upload a File

You can now upload blobs (files) to your container!

  1. Click on the container you created, then select Upload.
  2. Browse for a file to upload. Pick any random image that's lying around in your computer files! Select it and then select Upload.
  3. Select the Blob (which is the image) you just uploaded, find the URL field, click on the blue icon (copy button) next to the URL.
  4. Open a new browser tab and paste the URL. You should receive an error message saying that the resource does not exist. This is because we set Anonymous access level to Private! Let's fix this in the next step.

Change the access level of your blob

  1. Keep the tab with the error, but let's click back to your tab with your Azure blob.
  2. Select the X button on the top right corner to return to your container view.
  3. Select Change access level.
  4. Set the Private access level to Blob (anonymous read access for blobs only).
This will enable a read-only access to the blob (file) for viewing purposes.
  1. Select OK.
  2. Refresh the tab and visit the URL related to the Blob (file). You'll see an image getting downloaded onto your computer!
  • Nice. Now you can open the file because you've changed the access level to Blob 😎

Congratulations! You've successfully created a storage account, added a container, uploaded blobs (files), and changed the access level to make your file accessible from the internet.