Creating Publicly Accessible Azure Blob Storage Using Azure CLI
Prerequisites
- Install the Azure CLI (opens in a new tab)
- Sign in to Azure using:
az login
- Ensure you have the necessary permissions to create resources in Azure.
Step 1: Create a Resource Group
az group create --name <resource-group-name> --location <location>
Replace:
<resource-group-name>
with your desired resource group name<location>
with your preferred Azure region (e.g.,eastus
)
Step 2: Create a Storage Account
az storage account create \
--name <storage-account-name> \
--resource-group <resource-group-name> \
--location <location> \
--sku Standard_LRS \
--kind StorageV2 \
--allow-blob-public-access true
Replace:
<storage-account-name>
with a unique name for your storage account.--allow-blob-public-access true
enables public access at the storage account level.
Step 3: Create a Blob Container with Public Access
az storage container create \
--account-name <storage-account-name> \
--name <container-name> \
--public-access blob
Replace:
<container-name>
with your desired container name.--public-access blob
allows anonymous read access to the blobs within the container.
Step 4: Upload a Blob to the Container
az storage blob upload \
--account-name <storage-account-name> \
--container-name <container-name> \
--name <blob-name> \
--file <file-path>
Replace:
<blob-name>
with the desired name for your blob.<file-path>
with the path to the file you want to upload.
Step 5: Access the Blob Publicly
Once uploaded, your blob will be publicly accessible via the following URL:
https://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>
You can share this URL, and anyone with it can access the blob without authentication.
Important Considerations
Security Implications
- Public Access Warning: Enabling public access allows anyone to access the blobs without authentication. Ensure that no sensitive data is stored in publicly accessible containers.
Storage Account-Level Setting
- The
--allow-blob-public-access
parameter controls whether containers in the storage account can have public access. If set tofalse
, no containers in the account can be made public, regardless of individual container settings.
Container-Level Setting
- The
--public-access blob
setting allows anonymous read access to blob content but not to container metadata or the list of blobs.
References
This guide provides a step-by-step approach to setting up a publicly accessible Azure Blob Storage container using the Azure CLI.