Azure DevOps AzCopy Authentication failed, it is either not correct, or expired, or does not have the correct permission

After looking at this issue, I figured out what could be the reason. As you might have already known that a new service principal will be created whenever you create a service connection in the Azure DevOps, I have explained this in detail here. To make the AzureFileCopy@4 task work, we will have to add a role assignment under the Role Assignment in the resource group. You can see this when you click on the Access control (IAM). You can also click on the Manage service connection roles in the service connection you had created for this purpose, which will redirect you to the IAM screen.

  1. Click on the +Add and select Add role assignment
  2. Select the role as either Storage Blob Data Contributor or Storage Blob Data Owner
  3. Click Next and add the service principal as a member, in the next screen search with the name of the service principal created, you can get this when you click on the Manage Service Principal in the Service Connection in the Azure DevOps.

enter image description here

  1. Click on Review + assign once everything is configured.
  2. Wait for a few minutes and run your pipeline again. Your pipeline should run successfully now.

You can follow the same fix when you get the error "Upload to container: '' in storage account: '' with blob prefix: ''"