Heyat Afroz
Heyat Afroz

Reputation: 49

Uploading File in Azure using CLI

I am trying to practice on the following tasks:

  1. Create Storage Account: az storage account create --name heyatafroz25 --resource-group user-fottsascvuzj

  2. Get Storage Account Key: az storage account keys list -g user-fottsascvuzj -n heyatafroz25

  3. Create Share Account: az storage share create --account-name heyatafroz25 --name key1 az storage share create --account-name heyatafroz25 --name key2

  4. Create Storage Directory: az storage directory create --account-name heyatafroz25 --name heyatdir1 --share-name key1 az storage directory create --account-name heyatafroz25 --name heyatdir2 --share-name key2

  5. Uploading the File

I was asked to create a index.php file which i created using the touch command.

Post that I am not sure what details to be considered for path and source. For path i took the present working directory

az storage file upload --account-name heyatafroz25 --account-key {ACCOUNT_KEY} --path /home/scrapbook/tutorial/index.php --share-name key1 --source /home/scrapbook/tutorial/index.php

Please suggest on the corrections in the 5th command.

Upvotes: 2

Views: 22134

Answers (2)

a.garg
a.garg

Reputation: 61

Try running the following command:

az storage file upload --account-name mystorageaccount --account-key myaccountkey --share-name myfileshare --path "myDirectory/index.php" --source "/home/scrapbook/tutorial/php-docs-hello-world/index.php"

Upvotes: 3

Gaurav Mantri
Gaurav Mantri

Reputation: 136146

Looking at the documentation for az storage file upload:

--source: Path of the local file to upload as the file content.

Essentially this is the path of the local file you want to upload.

--path: The path to the file within the file share. If the file name is omitted, the source file name will be used.

So assuming if you're uploading a file, it would be the name of the file you want the local file to be saved in the storage.

To elaborate further, let's say you have a local file called "image.png" and you want to save it as "logo.png", you will use the following command:

az storage file upload --account-name <account-name> --account-key <account-key> --share-name <share-name> --path logo.png --source image.png

Upvotes: 3

Related Questions