0
0
Azurecloud~5 mins

Why Azure Storage matters - Why It Works

Choose your learning style9 modes available
Introduction
Storing data safely and accessibly is a big challenge for many apps and services. Azure Storage helps by giving you a place in the cloud to keep files, backups, and data that your apps can use anytime from anywhere.
When you want to save photos or documents from a website so users can download them later.
When you need to keep backups of your important data to avoid losing it if something breaks.
When your app needs to share data between different parts or users without using your own servers.
When you want to store logs or records that grow over time and need to be accessed quickly.
When you want a simple way to keep data safe and available without managing physical hardware.
Commands
This command creates a new Azure Storage account named 'mystorageaccount123' in the 'myResourceGroup' resource group located in East US. The Standard_LRS SKU means your data is locally redundant 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 resource group where the storage account will be created.
--sku - Defines the replication and performance type for the storage.
This command creates a container named 'mycontainer' inside the storage account. 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.
Uploads a file named 'example.txt' from your local computer to the 'mycontainer' container in your storage account. This makes the file available in the cloud.
Terminal
az storage blob upload --account-name mystorageaccount123 --container-name mycontainer --name example.txt --file example.txt
Expected OutputExpected
Uploading blob to container mycontainer Upload blob succeeded
--container-name - Specifies the container where the file will be uploaded.
--name - Sets the name of the file in the cloud.
--file - Points to the local file to upload.
Lists all files (blobs) inside the 'mycontainer' container in a readable table format so you can see what is stored.
Terminal
az storage blob list --account-name mystorageaccount123 --container-name mycontainer --output table
Expected OutputExpected
Name BlobType Length LastModified ------------ ----------- --------- ------------------------- example.txt BlockBlob 1234 2024-06-01T12:00:00+00:00
--output - Formats the output for easier reading.
Key Concept

Azure Storage provides a safe, easy, and scalable place in the cloud to keep your data accessible anytime and from anywhere.

Common Mistakes
Using a storage account name that is not globally unique.
Azure requires storage account names to be unique across all users, so the creation will fail if the name is taken.
Choose a unique name by adding random numbers or your company name to avoid conflicts.
Trying to upload a file to a container that does not exist.
The upload command will fail because the destination container must exist before uploading files.
Always create the container first using the container create command before uploading blobs.
Not specifying the correct resource group or location when creating the storage account.
This can cause the storage account to be created in an unexpected place or fail if the resource group does not exist.
Verify the resource group exists and specify the desired location explicitly.
Summary
Create an Azure Storage account to have a cloud space for your data.
Make containers inside the storage account to organize your files.
Upload files to containers to store your data safely in the cloud.
List files in containers to check what data you have stored.