0
0
Azurecloud~5 mins

Storage commands in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Storage commands help you save and manage files and data in the cloud. They let you create storage spaces, upload files, and check what is stored, all from your computer.
When you want to save backups of your important files safely in the cloud.
When you need to share files with your team without emailing large attachments.
When your app needs a place to store images or documents it uses.
When you want to organize data in folders and control who can see or change it.
When you want to check what files are stored or remove old files to save space.
Commands
This command creates a new storage account named mystorageaccount123 in the resource group myResourceGroup located in eastus. It sets the storage type to Standard locally-redundant storage (LRS) which keeps multiple copies in the same region for safety.
Terminal
az storage account create --name mystorageaccount123 --resource-group myResourceGroup --location eastus --sku Standard_LRS
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount123", "location": "eastus", "name": "mystorageaccount123", "resourceGroup": "myResourceGroup", "sku": { "name": "Standard_LRS" }, "kind": "StorageV2", "statusOfPrimary": "available" }
--name - Sets the unique name for the storage account
--resource-group - Specifies the group where the account is created
--sku - Defines the storage type and redundancy
This command creates a container named mycontainer inside the storage account mystorageaccount123. Containers are like folders where you store your files (blobs).
Terminal
az storage container create --account-name mystorageaccount123 --name mycontainer
Expected OutputExpected
True
--account-name - Specifies which storage account to use
--name - Names the container to create
This command uploads a local file named example.txt to the container mycontainer in the storage account mystorageaccount123. The file will be stored as a blob named example.txt.
Terminal
az storage blob upload --account-name mystorageaccount123 --container-name mycontainer --name example.txt --file ./example.txt
Expected OutputExpected
{ "etag": "0x8D9123456789ABC", "lastModified": "2024-06-01T12:00:00+00:00", "requestId": "12345678-1234-1234-1234-123456789abc", "version": "2020-10-02" }
--container-name - Specifies the container to upload to
--name - Sets the blob name in the container
--file - Path to the local file to upload
This command lists all blobs (files) inside the container mycontainer in a readable table format. It helps you see what files are stored.
Terminal
az storage blob list --account-name mystorageaccount123 --container-name mycontainer --output table
Expected OutputExpected
Name Blob Type Length Last Modified ------------ ----------- -------- ------------------------- example.txt BlockBlob 1024 2024-06-01T12:00:00+00:00
--container-name - Specifies which container to list blobs from
--output - Formats the output for easy reading
Key Concept

If you remember nothing else from storage commands, remember: create a storage account, make a container, upload files, and list them to manage your cloud storage.

Common Mistakes
Using a storage account name that is already taken or invalid.
Storage account names must be unique across Azure and follow naming rules, otherwise creation fails.
Choose a unique, lowercase name between 3 and 24 characters with only letters and numbers.
Trying to upload a file without specifying the correct container name.
The upload command needs the container name to know where to put the file; missing or wrong name causes failure.
Always double-check the container name matches the one you created.
Not checking the output of commands to confirm success.
Without verifying output, you might think the file uploaded or container created when it did not.
Read the command output carefully to confirm the operation succeeded.
Summary
Create a storage account to hold your data safely in the cloud.
Make containers inside the account to organize your files.
Upload files to containers to store your data.
List blobs in containers to see what files you have stored.