Getting Started with Azure Blob Storage

Welcome to Azure Blob Storage, Microsoft's highly scalable and secure object storage solution for the cloud. This guide will walk you through the essential steps to get you up and running with Blob Storage.

What is Azure Blob Storage?

Azure Blob Storage is designed for storing massive amounts of unstructured data, such as text or binary data. It's optimized for scenarios that involve directly serving images or documents to a web browser, storing files for distributed access, streaming video and audio, storing data for backup and restore, disaster recovery, and archiving. Blob storage is a RESTful service that can be accessed from anywhere in the world via HTTP or HTTPS.

Key Concepts

Prerequisites

Before you begin, you'll need:

Step 1: Create an Azure Storage Account

You can create a storage account using the Azure portal, Azure CLI, or Azure PowerShell.

Using the Azure Portal:

  1. Sign in to the Azure portal.
  2. Click on Create a resource.
  3. Search for "Storage account" and select it.
  4. Click Create.
  5. Fill in the required fields: Subscription, Resource group, Storage account name (globally unique), Region, and Performance tier.
  6. Review and create the storage account.

Using the Azure CLI:

Open your terminal or command prompt and run the following commands:


# Log in to your Azure account
az login

# Set your subscription (replace )
az account set --subscription <your-subscription-id>

# Create a resource group (if you don't have one)
az group create --name myResourceGroup --location eastus

# Create a storage account
az storage account create \
    --name mystorageaccount <--replace-with-globally-unique-name> \
    --resource-group myResourceGroup \
    --location eastus \
    --sku Standard_LRS
        

Remember to replace mystorageaccount<--replace-with-globally-unique-name> with a globally unique name for your storage account.

Step 2: Create a Container

Containers organize your blobs. They are case-insensitive and must start with a letter or number.

Using the Azure Portal:

  1. Navigate to your storage account in the Azure portal.
  2. Under Data storage, click on Containers.
  3. Click + Container.
  4. Enter a name for your container (e.g., mycontainer) and set the public access level.
  5. Click Create.

Using the Azure CLI:


# Create a container (replace with your storage account name and desired container name)
az storage container create \
    --name mycontainer \
    --account-name mystorageaccount <--replace-with-your-storage-account-name> \
    --auth-mode login
        

Step 3: Upload a Blob

You can upload various types of files as blobs.

Using the Azure Portal:

  1. Navigate to your storage account and then to the container you created.
  2. Click Upload.
  3. Select the file you wish to upload.

Using the Azure CLI:

This example uploads a local file named example.txt to your container.


# Upload a blob (replace with your storage account name, container name, and local file path)
az storage blob upload \
    --account-name mystorageaccount <--replace-with-your-storage-account-name> \
    --container-name mycontainer \
    --name example.txt \
    --file /path/to/your/local/example.txt \
    --auth-mode login
        

You can upload multiple files or create directories within a container using the CLI or SDKs.

Step 4: Accessing Your Blob

Once uploaded, you can access your blob. The access method depends on the container's public access level.

If your container's access level is set to Blob or Container, you can access the blob directly via its URL:

https://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>

Next Steps

Congratulations! You've successfully created a storage account, a container, and uploaded a blob.

Explore Advanced Blob Storage Features