Featured resource
Tech Upskilling Playbook 2025
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Learn more
  • Labs icon Lab
  • Cloud
Azure icon
Labs

Interact with Azure Blobs Using REST

Azure provides a variety of ways to interact with Blob storage. You can manage and access Blob storage using the Azure portal, a command line, or your own custom code. In this hands-on lab, you will have the opportunity to work with Azure storage using the Azure Blob Service REST API. Using basic HTTP requests, you will download some data stored in a blob, modify it, and re-upload the modified data to the blob.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Last updated
Clock icon Aug 21, 2025

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Authenticate with the Azure Blob Service REST API and Download the File

    1. Log in to the provided VM using the Public IP address and credentials.
    2. Create a signed authorization header in order to authenticate. To do so, we first need to set some temporary environment variables to aid in some future commands. For the storage_account and access_key, provide the actual storage account name and access key. One way to obtain these is to log in to the Azure portal. The access key can be found by clicking the storage account, then clicking Access Keys.
    request_date=$(TZ=GMT date "+%a, %d %h %Y %H:%M:%S %Z")
    storage_service_version="2015-04-05"
    storage_account="your storage account name"
    access_key="your storage account access key"
    resource="/${storage_account}/records/cars"
    request_method="GET"
    
    1. Create a temporary environment variable containing the list of headers that need to be signed:
    headers="x-ms-date:$request_date\nx-ms-version:$storage_service_version"
    
    1. Create a variable that contains the full string that will be signed:
    string_to_sign="${request_method}\n\n\n\n\n\n\n\n\n\n\n\n${headers}\n${resource}"
    
    1. Create a variable that contains the access key decoded and converted to hex:
    hex_key="$(echo -n $access_key | base64 -d -w0 | xxd -p -c256)"
    
    1. Generate the signature and Authorization header:
    signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$hex_key" -binary |  base64 -w0)
    authorization_header="SharedKey $storage_account:$signature"
    

    8.Download the Blob data to a local file:

    curl -H "x-ms-date:$request_date" 
      -H "x-ms-version:$storage_service_version" 
      -H "Authorization: $authorization_header" 
      "https://${storage_account}.blob.core.windows.net/records/cars" > cars.csv
    
    1. Verify the file contains the data. You should see a comma-delimited list of records representing various cars:
    cat cars.csv
    
  2. Challenge

    Modify the File and Re-Upload it to Blob Storage

    1. Edit the data file:
    vi cars.csv
    
    1. Add the new customer record to the end of the file:
    57991237,2020,Tesla,Cybertruck,X3B-33
    
    1. Generate a new authorization header:
    request_date=$(TZ=GMT date "+%a, %d %h %Y %H:%M:%S %Z")
    request_method="PUT"
    content_type="text/plain"
    file_length=$(wc -m < cars.csv)
    headers="x-ms-blob-type:BlockBlob\nx-ms-date:$request_date\nx-ms-version:$storage_service_version"
    string_to_sign="${request_method}\n\n\n$file_length\n\n$content_type\n\n\n\n\n\n\n${headers}\n${resource}"
    hex_key="$(echo -n $access_key | base64 -d -w0 | xxd -p -c256)"
    signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$hex_key" -binary |  base64 -w0)
    authorization_header="SharedKey $storage_account:$signature"
    
    1. Upload the modified data to the Blob.
    curl -X PUT -H "x-ms-blob-type:BlockBlob" 
      -H "x-ms-date:$request_date" 
      -H "x-ms-version:$storage_service_version" 
      -H "Authorization: $authorization_header" 
      -H "Content-Length:$file_length" 
      -H "Content-Type:$content_type" 
      --data-binary "@cars.csv" 
      "https://${storage_account}.blob.core.windows.net/records/cars"
    
    1. If you wish, you can locate the Blob in the Azure portal and click Edit to verify that your changes appear.

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.