Get Started with Azure Blob Storage
Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data, such as text or binary data. This guide will walk you through the fundamental steps to get started with Azure Blob Storage, including creating a storage account, creating a container, and uploading your first blob.
1. Create an Azure Storage Account
A storage account is a unique namespace in Azure that provides access to Azure Storage data objects. All objects in Azure Storage are managed by a storage account. You can create a storage account using the Azure portal, Azure CLI, or PowerShell.
Using the Azure Portal:
- Sign in to the Azure portal.
- In the search bar, type "Storage accounts" and select it.
- Click "Create".
- Select your subscription and resource group.
- Enter a unique name for your storage account.
- Choose a region.
- Select the performance tier (Standard is recommended for most scenarios).
- For redundancy, choose "Locally-redundant storage (LRS)" for basic needs or "Geo-redundant storage (GRS)" for higher durability.
- Review and create the storage account.
Using Azure CLI:
az storage account create \
--name mystorageaccountname \
--resource-group myresourcegroup \
--location westus \
--sku Standard_LRS \
--kind StorageV2
Replace mystorageaccountname and myresourcegroup with your desired names.
2. Create a Container
Blobs are stored in containers. A container is similar to a directory in a file system. You can create containers using the Azure portal, Azure CLI, or Azure Storage Explorer.
Using the Azure Portal:
- Navigate to your newly created storage account.
- Under "Data storage", select "Containers".
- Click "+ Container".
- Enter a name for your container (e.g.,
my-first-container). - Choose a public access level (Private is the default and recommended for most scenarios).
- Click "Create".
Using Azure CLI:
az storage container create \
--name my-first-container \
--account-name mystorageaccountname \
--auth-mode login
Replace my-first-container and mystorageaccountname.
3. Upload Your First Blob
Now that you have a storage account and a container, you can upload files (blobs) to it. You can upload various types of files, including images, documents, videos, and application data.
Using the Azure Portal:
- Navigate to your container.
- Click "Upload".
- Browse to select the file you want to upload.
- Optionally, you can set advanced options such as block blob type and metadata.
- Click "Upload".
Using Azure CLI:
az storage blob upload \
--account-name mystorageaccountname \
--container-name my-first-container \
--name my-local-file.txt \
--file /path/to/your/my-local-file.txt \
--auth-mode login
Replace mystorageaccountname, my-first-container, and the file paths accordingly.
Next Steps
Congratulations! You've successfully created an Azure Storage account, a container, and uploaded your first blob. Here are some recommended next steps:
- Explore different blob types: block blobs, append blobs, and page blobs.
- Learn how to download, delete, and manage blobs.
- Understand access control mechanisms like shared access signatures (SAS) and access control lists (ACLs).
- Integrate Blob Storage with other Azure services like Azure Functions or Azure App Service.