0% found this document useful (0 votes)
14 views

Create, Download, and List Blobs With Azure CLI

Uploaded by

Sanskar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
14 views

Create, Download, and List Blobs With Azure CLI

Uploaded by

Sanskar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
‘22124, 5:10 PM Quickstart: Upload, download, and list blobs - Azure CLI Azure Storage | Microsoft Learn Quickstart: Create, download, and list blobs with Azure CLI Article + 10/12/2023 The Azure CLI is Azure's command-line experience for managing Azure resources. You can use it in your browser with Azure Cloud Shell. You can also install it on macOS, Linux, or Windows and run it from the command line. In this quickstart, you learn to use the Azure CLI to upload and download data to and from Azure Blob storage. Prerequisites To access Azure Storage, you'll need an Azure subscription. If you don't already have a subscription, create a free account _ before you begin All access to Azure Storage takes place through a storage account. For this quickstart, create a storage account using the Azure portal, Azure PowerShell, or Azure CLI. For help creating a storage account, see Create a storage account. Prepare your environment for the Azure CLI * Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell. * Ifyou prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container, © Ifyou're using a local installation, sign in to the Azure CL by using the az login command. To finish the authentication process, follow the steps displayed in your terminal, For other sign-in options, see Sign in with the Azure CLI, © When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI. © Run az version to find the version and dependent libraries that are installed, To upgrade to the latest version, run az upgrade, nttps:leam microsof.comlen-ustazuelstorage/lobsistorage-quickstart-blabs- \ --location nttps:leam microsof.comlen-ustazuelstorage/lobsistorage-quickstart-blabs- \ --resource-group \ --location \ --sku Standard_ZRS \ --encryption-services blob Create a container Blobs are always uploaded into a container. You can organize groups of blobs in containers similar to the way you organize your files on your computer in folders. Create a container for storing blobs with the az storage container create command. The following example uses your Microsoft Entra account to authorize the operation to create the container. Before you create the container, assign the Storage Blob Data Contributor role to yourself, Even if you are the account owner, you need explicit permissions to perform data operations against the storage account. For more information about assigning Azure roles, see Assign an Azure role for access to blob data, Remember to replace placeholder values in angle brackets with your own values: azure CLI az ad signed-in-user show --query id -o tsv | az role assignment create \ =-role "Storage Blob Data Contributor" \ --assignee @- \ --scope "/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts / az storage container create \ --account-name \ ntips:/leam microsof.comlen-ustazuelstorage/lobsistorage-quickstart-blabs- \ --auth-mode login © Important Azure role assignments may take a few minutes to propagate. You can also use the storage account key to authorize the operation to create the container. For more information about authorizing data operations with Azure CLI, see ‘Authorize access to blob or queue data with Azure CLI. Upload a blob Blob storage supports block blobs, append blobs, and page blobs. The examples in this quickstart show how to work with block blobs. First, create a file to upload to a block blob. If you're using Azure Cloud Shell, use the following command to create a file Bash vi helloworld When the file opens, press insert. Type Hello world, then press Esc. Next, type -x, then press Enter. In this example, you upload a blob to the container you created in the last step using the az storage blob upload command. It's not necessary to specify a file path since the file was created at the root directory. Remember to replace placeholder values in angle brackets with your own values: ‘Azure CLI az storage blob upload \ --account-name \ --container-name \ --name myFile.txt \ --file myFile.txt \ --auth-mode login nttps:leam microsof.comlen-ustazuelstorage/lobsistorage-quickstart-blabs- \ ‘container-name \ --output table \ auth-mode login Download a blob Use the az storage blob download command to download the blob you uploaded earlier. Remember to replace placeholder values in angle brackets with your own values: Azure CLI az storage blob download \ --account-name \ container-name \ name myFile.txt \ File <+/destination/path/for/File> \ auth-mode login Data transfer with AzCopy The AzCopy command-line utility offers high-performance, scriptable data transfer for ‘Azure Storage. You can use AzCopy to transfer data to and from Blob storage and Azure nttps:leam microsof.comlen-ustazuelstorage/lobsistorage-quickstart-blabs- \ Next steps In this quickstart, you learned how to transfer files between a local file system and a container in Azure Blob storage. To learn more about working with Blob storage by using Azure CLI, select an option below. nttps:leam microsof.comlen-ustazuelstorage/lobsistorage-quickstart-blabs-

You might also like