9

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'
Kenny_I
  • 2,001
  • 5
  • 40
  • 94
  • This could be a 403 permission error. It uses different logic between version3 and version4 of this task, which causes the error. If we add the role to the ServicePrincipal/ Managed Identity, the issue would go away. – LoLance May 11 '20 at 06:58
  • Hi friend, is there any update for this issue? Not sure if the issue still persists to block you, feel free to let me know if you're still blocked. And if you're found the solution to it by yourself, please consider adding it as answer to share the useful info! So that more members with similar issue may benefit from that, thanks ~ – LoLance May 15 '20 at 02:52
  • Change the task version to 3 and check it should work. – Nayanajith Jul 06 '21 at 06:59

5 Answers5

21

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.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • 5
    Converting version from 4 to 3 worked for me. Cheers mate. – Mehmet Taha Meral Aug 23 '20 at 15:51
  • Yep, same here. Reverting to 'AzureFileCopy@3' is the only way to tackle the issue in my experience. – dperish Sep 01 '20 at 20:42
  • 1
    Adding the role assignment seems to take some time before it ripples through. Initially that change alone didn't work, so I want with version 3. Just when I want to report this as a bug, I tried version 4 again and this time it worked. So, after adding the role in our case we just had to wait for a few minutes until the change came into effect. – Manfred Nov 09 '20 at 03:37
  • same here changed azCopy task from version 5 to 3 to resolve the issue. don't know what's the issue with latest version of azCopy – KSP Nov 24 '22 at 10:00
  • I struggled to get v4 working just from this answer, but I found [this post](https://brettmckenzie.net/posts/azure-pipelines-copy-files-task-authentication-failed/) which goes into a bit more detail about exactly what you need to click on. – Craig Brown May 04 '23 at 11:07
2

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.

Brenners Daniel
  • 389
  • 5
  • 15
0

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

0

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

Niyi Aromokeye
  • 411
  • 5
  • 9
0

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.

Quyết
  • 502
  • 5
  • 12