az storage blob upload-batch returns ErrorCode:BlobAlreadyExists error v2.34.0 on upload
See original GitHub issueDescribe the bug
Trying to upload a file to the ‘$web’ container for a static site with az storage blob upload-batch
from GitHub Actions is failing on the latest version of the cli v2.34.0 saying that the blob already exists. The errors says to use --overwrite
.
ERROR: The specified blob already exists.
RequestId:5a838987-601e-002b-6577-2d31d6000000
Time:2022-03-01T14:17:46.5388178Z
ErrorCode:BlobAlreadyExists
If you want to overwrite the existing one, please add --overwrite in your command.
Adding --overwrite command results in this error:
ERROR: argument --overwrite: expected one argument
To Reproduce Setup a GitHub Actions workflow to upload directory to a storage blob;
- name: Login to Azure CLI
uses: azure/login@v1
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- name: Upload to blob storage
uses: azure/CLI@v1
env:
STORAGE_NAME: sadatastoresearchdev
with:
azcliversion: latest
inlineScript: |
az storage blob upload-batch --account-name ${{ env.STORAGE_NAME }} -d '$web' -s dist/
Expected behavior You should be able to upload the blob and overwrite as you could before.
Environment summary
https://github.com/Azure/cli in GitHub Actions
Additional context
Specifying an older azcliversion version v2.33.1 in the workflow allow you to upload the blob.
- name: Login to Azure CLI
uses: azure/login@v1
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- name: Upload to blob storage
uses: azure/CLI@v1
env:
STORAGE_NAME: sadatastoresearchdev
with:
azcliversion: 2.33.1
inlineScript: |
az storage blob upload-batch --account-name ${{ env.STORAGE_NAME }} --auth-mode key -d '$web' -s dist/
Detailed logs from GitHub Actions:
022-03-01T14:17:06.8368067Z ##[group]Run azure/login@v1
2022-03-01T14:17:06.8368444Z with:
2022-03-01T14:17:06.8370124Z creds: ***
2022-03-01T14:17:06.8370507Z enable-AzPSSession: false
2022-03-01T14:17:06.8370913Z environment: azurecloud
2022-03-01T14:17:06.8371321Z allow-no-subscriptions: false
2022-03-01T14:17:06.8371762Z audience: api://AzureADTokenExchange
2022-03-01T14:17:06.8372170Z env:
2022-03-01T14:17:06.8373821Z AZURE_CREDENTIALS: ***
2022-03-01T14:17:06.8374471Z STORAGE_KEY: ***
2022-03-01T14:17:06.8374823Z ##[endgroup]
2022-03-01T14:17:15.8274876Z [command]/usr/bin/az cloud set -n azurecloud
2022-03-01T14:17:21.4767300Z Done setting cloud: "azurecloud"
2022-03-01T14:17:23.0710370Z Login successful.
2022-03-01T14:17:23.0894436Z ##[group]Run azure/CLI@v1
2022-03-01T14:17:23.0894808Z with:
2022-03-01T14:17:23.0895130Z azcliversion: latest
2022-03-01T14:17:23.0895667Z inlineScript: az storage blob upload-batch --account-name sadatastoresearchdev -d '$web' -s dist/
2022-03-01T14:17:23.0896146Z env:
2022-03-01T14:17:23.0897712Z AZURE_CREDENTIALS: ***
2022-03-01T14:17:23.0898317Z STORAGE_KEY: ***
2022-03-01T14:17:23.0898675Z AZURE_HTTP_USER_AGENT:
2022-03-01T14:17:23.0899158Z AZUREPS_HOST_ENVIRONMENT:
2022-03-01T14:17:23.0899547Z STORAGE_NAME: sadatastoresearchdev
2022-03-01T14:17:23.0899947Z ##[endgroup]
2022-03-01T14:17:23.1710590Z Starting script execution via docker image mcr.microsoft.com/azure-cli:latest
2022-03-01T14:17:45.3477491Z WARNING:
2022-03-01T14:17:45.3478765Z There are no credentials provided in your command and environment, we will query for account key for your storage account.
2022-03-01T14:17:45.3583025Z It is recommended to provide --connection-string, --account-key or --sas-token in your command as credentials.
2022-03-01T14:17:45.3583675Z
2022-03-01T14:17:45.3598136Z You also can add `--auth-mode login` in your command to use Azure Active Directory (Azure AD) for authorization if your login account is assigned required RBAC roles.
2022-03-01T14:17:45.3599424Z For more information about RBAC roles in storage, visit https://docs.microsoft.com/azure/storage/common/storage-auth-aad-rbac-cli.
2022-03-01T14:17:45.3599847Z
2022-03-01T14:17:45.3600793Z In addition, setting the corresponding environment variables can avoid inputting credentials in your command. Please use --help to get more information about environment variable usage.
2022-03-01T14:17:46.6529259Z ERROR: The specified blob already exists.
2022-03-01T14:17:46.6530651Z RequestId:5a838987-601e-002b-6577-2d31d6000000
2022-03-01T14:17:46.6531594Z Time:2022-03-01T14:17:46.5388178Z
2022-03-01T14:17:46.6532370Z ErrorCode:BlobAlreadyExists
2022-03-01T14:17:46.6533513Z If you want to overwrite the existing one, please add --overwrite in your command.
2022-03-01T14:17:46.9476322Z ##[error]Error: az cli script failed.
2022-03-01T14:17:46.9487839Z cleaning up container...
2022-03-01T14:17:46.9851133Z MICROSOFT_AZURE_CLI_1646144243123_CONTAINER
2022-03-01T14:17:46.9851724Z
2022-03-01T14:17:46.9910045Z (node:1739) UnhandledPromiseRejectionWarning: Error: az cli script failed.
2022-03-01T14:17:46.9913655Z at /home/runner/work/_actions/azure/CLI/v1/dist/index.js:1:23964
2022-03-01T14:17:46.9914390Z at Generator.throw (<anonymous>)
2022-03-01T14:17:46.9915105Z at rejected (/home/runner/work/_actions/azure/CLI/v1/dist/index.js:1:20436)
2022-03-01T14:17:46.9915949Z at processTicksAndRejections (internal/process/task_queues.js:93:5)
2022-03-01T14:17:46.9917419Z (node:1739) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2022-03-01T14:17:46.9919329Z (node:1739) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2022-03-01T14:17:46.9996553Z Post job cleanup.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:14 (5 by maintainers)
Top Results From Across the Web
az storage blob | Microsoft Learn
Upload blobs or subdirectories to a storage blob directory. az storage ... Return all user-defined metadata for the specified blob or snapshot. az...
Read more >AzureBlob Upload ERROR:The specified blob already exists
I got an Error:"The specified blob already exists" when uploading file with same file( I want to overwrite the file) from azure.storage.blob ...
Read more >Error from az storage blob upload-batch command in Azure ...
When trying to run this command from an Azure Devops release task. The task is a Azure CLI (Preview) V2 with Powershell core...
Read more >azure-cli-storage 2.4.3 - PyPI
2.3.2. storage file download-batch : add –snapshot to download from a share snapshot. storage blob download-batch/upload-batch - adjust progress bar to be ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yet more breaking changes marked with ‘patch’ numbers. Is it so hard to follow SemVer and mark it as new release and not cause customers workloads to fail which have been working for YEARS!
You need to do
--overwrite true