Using Blob Storage from the Azure Cloud Shell

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

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.
  1. 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&ltunique string>"
  2. 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="&ltresource group name>"
  3. Create the storage account:
    az storage account create 
    --name $AZURE_STORAGE_ACCOUNT 
    --resource-group $RESOURCE_GROUP 
    --location westus 
    --sku Standard_LRS 
    --encryption-services blob
  4. Get keys for the storage account:
    az storage account keys list 
    --account-name $AZURE_STORAGE_ACCOUNT 
    --resource-group $RESOURCE_GROUP 
    --output table
  5. Set an environment variable containing the storage account key so that future commands can authenticate:
    export AZURE_STORAGE_KEY="&ltkey>"
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
  1. Download the data file:
    wget https://raw.githubusercontent.com/linuxacademy/content-azurestoragedd-lab-resources/master/satt-special-cars.csv
  2. Upload the data as a new blob:
    az storage blob upload 
    --container-name records 
    --name cars 
    --file satt-special-cars.csv
  3. List existing blobs and verify that your new blob appears in the list:
    az storage blob list 
    --container-name records 
    --output table
  4. 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

Additional Resources

You have been hired by a Store-all-the-things, the company that can store anything. Several of the company's customers are using the company's services to store their expensive cars. The vehicle storage division has a simple data file containing information about these cars and in which storage units they are located. They want to store this data in Azure to take advantage of the data integrity guarantees offered by the cloud.

Your task is to upload a copy of the data file as an Azure blob. You can do this using the Azure cloud shell. You can access the cloud shell at https://shell.azure.com. When accessing the shell, select Advanced settings, and use the existing storage account that resides in the West US location.

You will need to:

  • Create a storage account with a name that begins with sattrecords.
  • Create a container within the account called records.
  • Download a copy of the data file from: https://raw.githubusercontent.com/linuxacademy/content-azurestoragedd-lab-resources/master/satt-special-cars.csv
  • Upload the data to a new blob called cars.
  • Download the blob data and verify that it is stored correctly.

If you get stuck, feel free to check out the solution video, or the detailed instructions under each objective. Good luck!

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?