"Directory is expected, not a file." error when using Azure CLI to download from blob storage

58 Views Asked by At

I have this in my CI/CD pipeline:

az storage blob download-batch --destination "extraction" --source azure_container --auth-mode login --account-name az_account_name

When running it (as part of my full pipeline), I get this:

ERROR:[Errno 20] Not a directory:'extraction/config-0000/scripts' 
Directory is expected, not a file.

I dont get why. config-0000 is a directory in the container azure_container. Inside, we have folder, which contain folder, which contain json files.

I just want to download the full folder structure and files from within the container.

Ironically, uploading via az storage blob upload-batch works like a charm...

Any idea on how to do this?

1

There are 1 best solutions below

2
Venkatesan On

I just want to download the full folder structure and files from within the container.

The error "Directory is expected, not a file" tells that the destination path specified in the --destination parameter is not a directory. Also, check the extractionfolder in the same directory which you're running the command on your system.

In my environment, I have the Blob structure in my storage account.

a/abc
   05-03-2024.html
c/abc/employee
     temp.png
d/abc/employee
   mountainview.png 
g/abc
  bike.png     

Now, using the same command, I can download all files and folders from the Azure Blob storage.

Command:

az storage blob download-batch --destination "important" --source "sample" --account-name "venkat678" --auth-mode "login"

The above command is executed and downloads the exact structure in my environment.

Output:

PS C:\Users\v-vsettu> az storage blob download-batch --destination "important" --source "sample" --account-name "venkat678" --auth-mode "login" 2> $null
[
  "a/abc/05-03-2024.html",
  "c/abc/employee/temp.png",
  "d/abc/employee/mountainview.png",
  "g/abc/bike.png"
]

enter image description here

enter image description here

Reference: az storage blob | Microsoft Learn