Azure blob storage can be used to store nearly any kind of data. It can provide a complex storage backend for applications as well as a simple location to store the contents of important files. In this lab, you will have the opportunity to work through the simple process of creating a blob to store a simple data file.
You do not always need to interact with Azure using the Azure portal. You can do so using Bash, and Azure offers a bash interface called Azure Cloud Shell. You can use Azure Cloud Shell to interact with Azure from a command line in your browser. This lab will provide you with the opportunity not only to work with storage blobs but to work with them using Azure Cloud Shell.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create a storage account and configure authentication.
- Choose a storage account name. Include a unique string to ensure the name does not conflict with any existing storage account:
export AZURE_STORAGE_ACCOUNT="sattrecords<unique string>"
- Set an environment variable containing the resource group to be used in future commands. You can find the resource group name in the Azure portal:
export RESOURCE_GROUP="<resource group name>"
- Create the storage account:
az storage account create --name $AZURE_STORAGE_ACCOUNT --resource-group $RESOURCE_GROUP --location westus --sku Standard_LRS --encryption-services blob
- Get keys for the storage account:
az storage account keys list --account-name $AZURE_STORAGE_ACCOUNT --resource-group $RESOURCE_GROUP --output table
- Set an environment variable containing the storage account key so that future commands can authenticate:
export AZURE_STORAGE_KEY="<key>"
- Choose a storage account name. Include a unique string to ensure the name does not conflict with any existing storage account:
- Create a container.
Use the following command to create a container to contain the blob:
az storage container create --name records
- Upload the file as a blob and verify the data is stored in the blob
- Download the data file:
wget https://raw.githubusercontent.com/linuxacademy/content-azurestoragedd-lab-resources/master/satt-special-cars.csv
- Upload the data as a new blob:
az storage blob upload --container-name records --name cars --file satt-special-cars.csv
- List existing blobs and verify that your new blob appears in the list:
az storage blob list --container-name records --output table
- Download the blob data to a new file and check the file to verify that it contains the data:
az storage blob download --container-name records --name cars --file cars-dl.csv cat cars-dl.csv
- Download the data file: