AzureFileCopy@4 does not behave like AzureFileCopy@2/AzureFileCopy@3 when copying files.
See original GitHub issueQuestion, 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:
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:
- Created 3 years ago
- Comments:9 (5 by maintainers)
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 aBlobPrefix
, 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.AzCopy command that runs:
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.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
For AzureFileCopyV4 use like this.
I hope it helps