Create an Azure Storage Container

This tutorial guides you through the process of creating a new container in your Azure Storage account. Containers are used to group and organize blobs (files) within your storage account.

Note: A container is a logical grouping of blobs. You must have an Azure Storage account already created to proceed. If not, please follow the Create Storage Account tutorial first.

Prerequisites

Method 1: Using the Azure Portal

The Azure portal provides a user-friendly graphical interface for managing your Azure resources.

Steps:

  1. Sign in to the Azure Portal: Navigate to https://portal.azure.com/ and sign in with your Azure account credentials.
  2. Navigate to your Storage Account: In the portal's search bar, type "Storage accounts" and select it from the results. Then, click on the name of the storage account where you want to create the container.
  3. Access Containers: In the left-hand menu of your storage account, under the "Data storage" section, select Containers.
  4. Create a New Container: Click the + Container button at the top of the containers list.
  5. Configure Container Settings:

    A panel will appear with the following options:

    • Name: Enter a unique name for your container. Container names must be lowercase, start and end with a letter or number, and contain only letters, numbers, and hyphens.
    • Public access level: Choose the desired access level for your container. Options include:
      • Private (no anonymous access): Recommended for most scenarios.
      • Blob (anonymous read access for blobs only): Allows anonymous read access to blobs within the container.
      • Container (anonymous read access for containers and blobs): Allows anonymous read access to the container's metadata and blobs.
    Tip: For enhanced security, it's best practice to leave the public access level as Private unless you have a specific requirement for anonymous access.
  6. Create the Container: Click the Create button.

Your new container will now appear in the list of containers for your storage account.

Method 2: Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for scripting and automating Azure resource management.

Steps:

  1. Install Azure CLI: If you haven't already, install the Azure CLI from the official Microsoft documentation.
  2. Log in to Azure: Open your terminal or command prompt and run:
    az login
  3. Create the Container: Use the following command, replacing <storage-account-name>, <container-name>, and <resource-group-name> with your actual values:
    az storage container create --name <container-name> --account-name <storage-account-name> --resource-group <resource-group-name> --public-access off

    Explanation:

    • --name: Specifies the name of the container to create.
    • --account-name: The name of your storage account.
    • --resource-group: The resource group your storage account belongs to.
    • --public-access off: Sets the container to private access (recommended). You can change this to blob or container if needed.

Method 3: Using Azure PowerShell

Azure PowerShell provides another scripting option for managing your Azure resources.

Steps:

  1. Install Azure PowerShell: Install the Az PowerShell module if you haven't already. Refer to the official Microsoft documentation for installation instructions.
  2. Connect to Azure: Open PowerShell and run:
    Connect-AzAccount
    Follow the prompts to log in to your Azure account.
  3. Set Context (if necessary): If you have multiple subscriptions, set the context to the correct one:
    Set-AzContext -SubscriptionId "<your-subscription-id>"
  4. Create the Container: Use the following command, replacing <storage-account-name>, <container-name>, and <resource-group-name>:
    New-AzStorageContainer -Name "<container-name>" -Context (Get-AzStorageAccount -ResourceGroupName "<resource-group-name>" -Name "<storage-account-name>").Context -PublicAccess Off

    Explanation:

    • -Name: The name of the container.
    • -Context: Retrieves the storage account context, which includes authentication information.
    • -PublicAccess Off: Sets the container to private access.

Next Steps

Now that you have created a container, you can start uploading blobs (files) to it. Refer to the Upload Blobs to Azure Storage tutorial for more information.

Tip: Consider setting up access policies for your containers to grant specific permissions to users or applications, rather than relying on anonymous access.