Getting Started with Azure Blob Storage
Welcome to Azure Blob Storage! This guide will walk you through the fundamental steps to get started with storing and managing your unstructured data in the cloud.
1. Create an Azure Storage Account
A storage account is the foundation for all Azure Storage services. You need to create one before you can use Blob Storage.
- Sign in to the Azure portal.
- Search for "Storage accounts" and select it.
- Click "Create".
- Fill in the required details:
- Subscription: Choose your Azure subscription.
- Resource group: Create a new one or select an existing one.
- Storage account name: A globally unique name.
- Region: Select a geographic region.
- Performance: Standard is generally recommended for most workloads.
- Redundancy: Choose the redundancy option that best suits your needs (e.g., LRS, GRS).
- Click "Review + create" and then "Create".
2. Create a Container
Containers organize sets of blobs. Think of them like directories or folders in a file system.
- Navigate to your newly created storage account in the Azure portal.
- In the left-hand menu, under "Data storage", select "Containers".
- Click "+ Container".
- Provide a Name for your container (e.g., `my-first-container`). Names must be lowercase.
- Set the Public access level. For most scenarios, "Private (no anonymous access)" is the most secure option.
- Click "Create".
3. Upload a Blob
Now you can upload your files (blobs) into the container.
- Click on the container you just created.
- Click the "Upload" button.
- Use the file picker to select the file you want to upload.
- You can also specify advanced settings like blob type (Block blob, Append blob, Page blob) and access tier. For most files, "Block blob" is suitable.
- Click "Upload".
Tip: You can also use the Azure CLI, Azure PowerShell, or SDKs to programmatically manage your storage account and blobs.
Example: Using Azure CLI
To create a storage account and upload a file using Azure CLI:
# Log in to Azure (if you haven't already)
az login
# Set your subscription context
az account set --subscription ""
# Define variables
RESOURCE_GROUP="myResourceGroup"
STORAGE_ACCOUNT_NAME="mystorageaccount$(openssl rand -hex 3)" # Example of a unique name
LOCATION="eastus"
CONTAINER_NAME="mycli-container"
BLOB_NAME="my-cli-file.txt"
LOCAL_FILE_PATH="./my-cli-file.txt" # Create this file locally
# Create a resource group
az group create --name $RESOURCE_GROUP --location $LOCATION
# Create a storage account
az storage account create --name $STORAGE_ACCOUNT_NAME --resource-group $RESOURCE_GROUP --location $LOCATION --sku Standard_LRS
# Create a container
az storage container create --name $CONTAINER_NAME --account-name $STORAGE_ACCOUNT_NAME --auth-mode login
# Upload a blob
az storage blob upload --container-name $CONTAINER_NAME --name $BLOB_NAME --file $LOCAL_FILE_PATH --account-name $STORAGE_ACCOUNT_NAME --auth-mode login
echo "Blob '$BLOB_NAME' uploaded to container '$CONTAINER_NAME' in storage account '$STORAGE_ACCOUNT_NAME'."
Next Steps
Congratulations on uploading your first blob! You can now explore more advanced features of Azure Blob Storage:
Manage Containers Upload & Download