Skip to content

Working with Azure Storage using Azure CLI

This article goes through how to use the Azure CLI and interact with Azure Storage on MedStack.

Prerequisite: Create a SAS token in MedStack Control

What does this article cover:

  1. Install Azure CLI
  2. Using Azure CLI inside a container on MedStack
  3. Using Azure CLI on your work station

Install Azure CLI

The Azure CLI is available to install in Windows, macOS and Linux environments.

Using Azure CLI inside a container on MedStack

This section goes through how to use Azure CLI in a container running on MedStack.

Azure Storage CLI

You may reference the official Azure Blob documentation to review the various CLI commands: https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest

Below are some examples of common CLI commands.

List blobs in a container

az storage blob list --account-name medstackstorage3dpcio0cq -c container-1 --sas-token "sp=racwdl&sv=2018-11-09&sr=c&st=2021-09-30T19%3A18%3A00Z&se=2021-10-09T12%3A00%3A00Z&spr=https&sig=%2BMC4S2MU9KuSrkq92J90gusLfSU%2FRpULS%2FpmsZZ6JIQ%3D"

Upload file to a container

az storage blob upload --account-name "medstackstorage3dpcio0cq" -c container-1 -f ./test_file.txt -n test_file_jot.txt --sas-token "sp=racwdl&sv=2018-11-09&sr=c&st=2021-09-30T19%3A18%3A00Z&se=2021-10-09T12%3A00%3A00Z&spr=https&sig=%2BMC4S2MU9KuSrkq92J90gusLfSU%2FRpULS%2FpmsZZ6JIQ%3D"

Output

{
  "etag": "\"0x8D98460E4FDE17D\"",
  "lastModified": "2021-09-30T22:23:14+00:00"
}

Download file from the container

az storage blob download --account-name "medstackstorage3dpcio0cq" -c container-1 -f ./jot_test.txt -n test_file_jot_2.txt --sas-token "sp=racwdl&sv=2018-11-09&sr=c&st=2021-09-30T19%3A18%3A00Z&se=2021-10-09T12%3A00%3A00Z&spr=https&sig=%2BMC4S2MU9KuSrkq92J90gusLfSU%2FRpULS%2FpmsZZ6JIQ%3D"

Output

{
  "content": null,
  "deleted": false,
  "metadata": {},
  "name": "test_file_jot.txt",
  "properties": {
    "appendBlobCommittedBlockCount": null,
    "blobTier": null,
    "blobTierChangeTime": null,
    "blobTierInferred": false,
    "blobType": "BlockBlob",
    "contentLength": 72,
    "contentRange": "bytes 0-71/72",
    "contentSettings": {
      "cacheControl": null,
      "contentDisposition": null,
      "contentEncoding": null,
      "contentLanguage": null,
      "contentMd5": "yLNcRWzKM304gjSjrloDwA==",
      "contentType": "text/plain"
    },
    "copy": {
      "completionTime": null,
      "id": null,
      "progress": null,
      "source": null,
      "status": null,
      "statusDescription": null
    },
    "creationTime": "2021-09-30T19:28:13+00:00",
    "deletedTime": null,
    "etag": "\"0x8D9844871F5A38D\"",
    "lastModified": "2021-09-30T19:28:13+00:00",
    "lease": {
      "duration": null,
      "state": "available",
      "status": "unlocked"
    },
    "pageBlobSequenceNumber": null,
    "remainingRetentionDays": null,
    "serverEncrypted": true
  },
  "snapshot": null
}

Using Azure CLI on your workstation

Using the Azure CLI on your workstation or any other location outside of your MedStack cluster is similar to using the CLI from within a container running on MedStack Control except for the steps on creating the SAS token.

Refer to the following subsections of creating a SAS token.