Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

azure-devops

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'
like image 906
Kenny_I Avatar asked May 08 '20 14:05

Kenny_I


People also ask

How do I log into AzCopy?

The client secret or certificate password must be placed in the appropriate environment variable. Type AzCopy env to see names and descriptions of environment variables. --tenant-id (string) The Azure Active Directory tenant ID to use for OAuth device interactive login.

How do I copy files from Azure Blob storage to Azure VM?

We need to start this command with the utility name, azCopy, followed by the "sync" command, which will help sync files between two locations. Then we need to provide the source location from where the files will be synced. Lastly, we need to provide a destination, a complete path of the Azure Blob storage container.

Where is Azure blob storage?

Objects in Blob Storage are accessible via the Azure Storage REST API, Azure PowerShell, Azure CLI, or an Azure Storage client library.


1 Answers

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.

like image 133
LoLance Avatar answered Sep 19 '22 00:09

LoLance