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.
Prerequisites
- An Azure subscription.
- An Azure Storage account.
Method 1: Using the Azure Portal
The Azure portal provides a user-friendly graphical interface for managing your Azure resources.
Steps:
- Sign in to the Azure Portal: Navigate to https://portal.azure.com/ and sign in with your Azure account credentials.
- 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.
- Access Containers: In the left-hand menu of your storage account, under the "Data storage" section, select Containers.
- Create a New Container: Click the + Container button at the top of the containers list.
-
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. - 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:
- Install Azure CLI: If you haven't already, install the Azure CLI from the official Microsoft documentation.
-
Log in to Azure:
Open your terminal or command prompt and run:
az login
-
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 offExplanation:
--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 toblob
orcontainer
if needed.
Method 3: Using Azure PowerShell
Azure PowerShell provides another scripting option for managing your Azure resources.
Steps:
- Install Azure PowerShell: Install the Az PowerShell module if you haven't already. Refer to the official Microsoft documentation for installation instructions.
-
Connect to Azure:
Open PowerShell and run:
Connect-AzAccountFollow the prompts to log in to your Azure account.
-
Set Context (if necessary):
If you have multiple subscriptions, set the context to the correct one:
Set-AzContext -SubscriptionId "<your-subscription-id>"
-
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 OffExplanation:
-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.