DEV Community

Wallism
Wallism

Posted on

1

AzCopy.exe exited with non-zero exit code while uploading files to blob storage

In Azure DevOps, trying to copy a file to Azure Storage using the Azure file copy task.

Initially we were using v3 and it had an error in a "Pre-job" task (but the task itself succeeded) with this error:
Unable to fetch storage account key. Error: '{0}' Error: Input required: ConnectedServiceNameSelector

In v2 of the task the error is:
Unable to fetch storage account key. Error: '{0}' TypeError: Cannot read property 'retrieveSecret' of undefined

The Fix

Under the hood the task must be creating a SAS token and then trying to upload to the blob storage. To fix the problem you need to ensure the Service Principal being used has these two roles on the Azure Storage Account:

Storage Account Contributor - "Lets you manage storage accounts, including accessing storage account keys which provide full access to storage account data."

Storage Blob Data Contributor - "Allows for read, write and delete access to Azure Storage blob containers and data"

You can add those roles in IAM
IAM
Add roles

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay