Kenny_I
Kenny_I

Reputation: 2513

AzureFileCopy with Azure DevOps pipeline fails - 'AzCopy.exe exited with non-zero exit

I try to copy ARM templates to storage but failing. What could wrong with YML?

ERROR:

& "AzCopy\AzCopy.exe" logout
INFO: Logout succeeded.
INFO: AzCopy.exe: A newer version 10.4.3 is available to download

Disconnect-AzAccount -Scope Process -ErrorAction Stop
Clear-AzContext -Scope Process -ErrorAction Stop
##[error]Upload to container: 'arm' in storage account: 'devopsstorageken' with blob prefix: 'test' 
failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' 
For more info please refer to https://aka.ms/azurefilecopyreadme
Finishing: AzureFileCopy

YML:

- task: AzureFileCopy@4
  inputs:
    SourcePath: '$(Build.Repository.LocalPath)/ARMTemplates/CreateSQLServerARM'
    azureSubscription: 'TestRG-Conn'
    Destination: 'AzureBlob'
    storage: 'devopsstorageken'
    blobPrefix: 'test'
    ContainerName: 'arm'

Upvotes: 11

Views: 15202

Answers (6)

Tony Dong
Tony Dong

Reputation: 3313

I had to go back from AzureFileCopy@6 to AzureFileCopy@3, no idea why!!!

Upvotes: 0

Quyết
Quyết

Reputation: 612

Just in case someone may encounter this issue again. I'm not sure what is the cause. But degrading the version of the task from AzureFileCopy@5 to AzureFileCopy@3 works for me. AzureFileCopy@4 does not work too.

Upvotes: 2

Brenners Daniel
Brenners Daniel

Reputation: 419

I also had to go back from AzureFileCopy@4 to AzureFileCopy@3. Since I am using Azure DevOps Pipelines, I already have the Contributor role for my Storage Account via my Service Connection.

However, I still have issues as soon as I configured TLS 1.2 as a requirement for my Storage Account. Currently, I can only work around the problem if I also allow TLS 1.0 here. The TLS option is the only way to get the task runnig.

Upvotes: 3

Niyi Aromokeye
Niyi Aromokeye

Reputation: 450

In addition to @lolance answer, watch out for your source path parameter. Do not use * after your trailing slash that is folder/build/*.

Upvotes: 0

Vishal Jain
Vishal Jain

Reputation: 1

Artifact PathPlease check the Source* correctly. Just to troubleshoot, provide the absolute path of the artifact and then try to deploy, you will able to do it.

Once you succeed, reverse engineer the things and work on the absolute path of the Source. It's working fine on Version 2.

Note: If you are using Extract Files task, then try to replace it with Unzip task

Upvotes: 0

LoLance
LoLance

Reputation: 28216

I try to copy ARM templates to storage but failing. What could wrong with YML?

Your yml looks right. I guess there might be something wrong with the task itself.

As a workaround we can use the AzureFileCopy@3, in this version we don't need to do any extra job in Azure Web Portal.

And in preview AzureFileCopy@4, there's some difference. We need to make sure the Service Principal we use in this task have access to the Storage Account. For me, I need to navigate to Access control page and Add a role assignment(Storage Blob Data Contributor/owner role) to my Service Principal/Managed Identity:

enter image description here

So that the AzureFileCopy version4 could also work on my side.

Upvotes: 23

Related Questions