question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AzureFileCopy@4 does not behave like AzureFileCopy@2/AzureFileCopy@3 when copying files.

See original GitHub issue

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzureFileCopy@4

Environment

  • Server - Azure Pipelines

  • Agent - Hosted:

Issue Description

This is my yaml definition: - task: AzureFileCopy@2 displayName: 'AzureBlob File Copy' condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) inputs: SourcePath: '$(build.artifactstagingdirectory)/Gaine.Utilities.zip' azureSubscription: 'Gainecorp' Destination: 'AzureBlob' storage: 'gainestorage' ContainerName: 'software' BlobPrefix: 'utilities'

When this runs, it copies the Gaine.Utilities.zip file to a “folder” called utilities in blob storage, i.e. /utilities/Gaine.Utilities.zip.

When I run the identical task using v4 (i.e. AzureFileCopy@4), it doesn’t act the same. It creates a file called ‘utilities’ that has no extension, but it has the expected contents. Meaning that if I download it and manually add a .zip extension, I can open it and find the expected contents.

The bottom entry is from a V4 task: image

Task logs

AzureFileCopy@2 content: Uploading files from source path: 'D:\a\1\a\Gaine.Utilities.zip' to storage account: 'gainestorage' in container: 'software' with blob prefix: 'utilities' & "AzCopy\AzCopy.exe" /Source:"D:\a\1\a" /Dest:"https://gainestorage.blob.core.windows.net/software/utilities" /@:"D:\a\_temp\gqnikfaxypsjfwesmu606n7b9" /XO /Y /SetContentType /Z:"AzCopy" /V:"AzCopy\AzCopyVerbose_e0f10ef1-7060-455e-966b-d9d873c5e2df.log" /S /Pattern:"Gaine.Utilities.zip"

AzureFileCopy@4 content: Uploading files from source path: 'd:\a\1\a\Gaine.Utilities.zip' to storage account: 'gainestorage' in container: 'software' with blob prefix: 'utilities' & "AzCopy\AzCopy.exe" copy "d:\a\1\a\Gaine.Utilities.zip" "https://gainestorage.blob.core.windows.net/software/utilities" --log-level=INFO --recursive

The V2 behavior is expected; the V4 behavior is not. What configuration changes are required to get V4 operating, or should I just stay with V2? By the way, V3 performs like V2, thankfully.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
enufacascommented, Jul 14, 2020

I ran into the same problem as described in the original post by Chris and I don’t believe it is a permission issue or related to #13159

In the v4 version of the task if you explicitly specify a single file in the SourcePath in combination with a BlobPrefix, the format of the AZ Copy command is ultimately missing a trailing slash. This causes the file that is uploaded to be created with the name of the Blob Prefix.

steps:
- task: AzureFileCopy@4
  displayName: 'AzureBlob File Copy'
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/directory/testFile.txt'
    azureSubscription: subscriptionName
    Destination: AzureBlob
    storage: storageaccountname
    ContainerName: downloadscontainer
    BlobPrefix: blobprefixname

AzCopy command that runs:

"AzCopy\AzCopy.exe" copy "D:\AgentA\_work\r193\a\directory\testFile.txt" "https://storageaccountname.blob.core.windows.net/downloadscontainer/blobprefixname"  --log-level=INFO --recursive

Note that the trailing slash is missing after blobprefixname/. You cannot add the trailing slash yourself as it is stripped out when the task executes.

As a work around -If you specify a star pattern in the SourcePath the file is uploaded as expected to the virtual directory.

0reactions
AmrutaKawadecommented, Feb 23, 2021

This is known issue

https://developercommunity.visualstudio.com/content/problem/1109500/azure-file-copy-task-drops-file-name-when-using-pr.html

and adding trailing slash will break most of the customers check this issue. https://github.com/microsoft/azure-pipelines-tasks/issues/13935

Till AzureFileCopy V3 you should use like below

Source Path : Gaine.Utilities.zip
Blob prefix : utilities
File Path : utilities/Gaine.Utilities.zip

For AzureFileCopyV4 use like this.

Source Path : Gaine.Utilities.zip
Blob prefix : utilities/Gaine.Utilities.zip
File Path : utilities/Gaine.Utilities.zip

I hope it helps

Read more comments on GitHub >

github_iconTop Results From Across the Web

AzureFileCopy@4 - Azure file copy v4 task | Microsoft Learn
The name of the container into which files are copied. If the specified container does not exist in the storage account, it will...
Read more >
Azure DevOps pipeline: Azure Copy Files step V4 error - can't ...
No matter what predefined variable I try to use, I always see the same error: failed to perform copy command due to error:...
Read more >
AzureFileCopy not working - Visual Studio Feedback
I'm getting this error "Storage account: ' not found. ... And are you running Azure File Copy as a task in a yaml...
Read more >
Azure DevOps: Azure File copy troubleshooting - Codewrecks
Azure File Copy task is based on azcopy command line, that has some default options, like journaling, not so useful for using in...
Read more >
Azure DevOps – Copy Files from git Repository to Azure ...
In my case, I have faced an error with the message Status: 403 This request is not authorized to perform this operation using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found