Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REGRESSION]: AzureFileCopyV6 uses wrong path for azcopy.exe #19705

Open
5 of 7 tasks
DHowett opened this issue Mar 28, 2024 · 19 comments
Open
5 of 7 tasks

[REGRESSION]: AzureFileCopyV6 uses wrong path for azcopy.exe #19705

DHowett opened this issue Mar 28, 2024 · 19 comments
Labels
Area: Release Area:RM RM task team bug p1 Priority 1 (should have immediate attention) regression This used to work, but a change in the service/tasks broke it.

Comments

@DHowett
Copy link
Member

DHowett commented Mar 28, 2024

New issue checklist

Task name

AzureFileCopy

Breaking task version

6

Last working task version

5

Regression Description

Builds consuming AzureFileCopy@6 fail with:

FAILING OUTPUT

& azcopy copy "C:\__w\1\s\_out\*"

The term 'azcopy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

PASSING OUTPUT

& "AzCopy\AzCopy.exe" copy "C:\__w\1\s\_out\*"

Notice the different path to AzCopy.exe.

I have pinpointed where in the task this change was made. This diff is the reason AzCopy is not found. The utility code is now ignoring the $azCopyExeLocation variable.

diff --git a/Utility.ps1 b/Utility.ps1
index 94beb25e9f..0d8272dd3d 100644
--- a/Utility.ps1
+++ b/Utility.ps1
@@ -242,23 +231,22 @@ function Upload-FilesToAzureContainer
         if ($useSanitizerActivate) {
             # Splitting arguments on space, but not on space inside quotes
             $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)')
             Write-Output "##[command] & azcopy copy `"$sourcePath`" `"$containerURL`" $sanitizedArguments"
-            & azcopy copy $sourcePath $containerURL$containerSasToken $sanitizedArguments
+            & azcopy copy $sourcePath $containerURL $sanitizedArguments
         } else {
-            Write-Output "##[command] & `"$azCopyExeLocation`" copy `"$sourcePath`" `"$containerURL`"  $additionalArguments"
-            $uploadToBlobCommand = "& `"$azCopyExeLocation`" copy `"$sourcePath`" `"$containerURL`" $additionalArguments"
-            Invoke-Expression $uploadToBlobCommand
+            Write-Output "##[command] & azcopy copy `"$sourcePath`" `"$containerURL`" $additionalArguments"
+            $azCopyCommand = "azcopy copy `"$sourcePath`" `"$containerURL`"  $additionalArguments"
+            Invoke-Expression -Command $azCopyCommand
         }

image

Regressed in #19650

This change was made in every instance where azcopy is invoked. /cc @v-mohithgc

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows

Relevant log output

Log output included above.

Full task logs with system.debug enabled

Log output included above.

Repro steps

No response

@DHowett DHowett added bug regression This used to work, but a change in the service/tasks broke it. labels Mar 28, 2024
@geekzter
Copy link
Member

@DHowett Thanks for creating the issue in this repo. Is this happening on Microsoft hosted or agent or a self-hosted agent? If the latter, what PowerShell version is installed?
@v-mohithgc @manolerazvan

@DHowett
Copy link
Member Author

DHowett commented Mar 28, 2024

Technically self-hosted; Microsoft internal (OneBranch). However... the issues I pointed out in the script are true regardless of the agent and powershell version, I believe. 🙂

@DHowett
Copy link
Member Author

DHowett commented Mar 28, 2024

Yes, judging by the contents of the task's make.json:

    "externals": {
        "archivePackages": [
            {
                "url": "https://vstsagenttools.blob.core.windows.net/tools/azcopy/10.12/AzCopy.zip",
                "dest": "./"
            }
        ],
// ...

... and the contents of that archive ...

$ tar tf .\AzCopy.zip
AzCopy/AzCopy.exe

the path to azcopy.exe must contain AzCopy/, otherwise the task is actually taking a dependency on the azcopy.exe available in the environment. This means that the task, instead of using AzCopy 10.12 which it ships with, will use whatever AzCopy is on the machine already. That can result in significant regressions if the agent contains an older AzCopy.

@rdumitru
Copy link

We're also encountering the exact same issue for our internal Microsoft pipelines. v4 worked really well, but we've been waiting for v6 to use it with workload identity service connections.

@v-mohithgc v-mohithgc added p1 Priority 1 (should have immediate attention) Area:RM RM task team and removed triage labels Apr 3, 2024
@DevTestUser123
Copy link

DevTestUser123 commented Apr 4, 2024

Still getting same error:

failed with error: 'The term 'azcopy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.' For more info please refer to https://aka.ms/azurefilecopyreadme

@v-mohithgc @DHowett

@v-mohithgc
Copy link
Contributor

Still getting same error:

failed with error: 'The term 'azcopy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.' For more info please refer to https://aka.ms/azurefilecopyreadme

@v-mohithgc @DHowett

Hi @DevTestUser123, the changes have been merged today and it will take 5-7 working days to be deployed on all the regions.
The new version of the task (ie 6.238.0) will contain the fix.

@DHowett
Copy link
Member Author

DHowett commented Apr 11, 2024

@DevTestUser123 Look, friend, I just reported the bug and the fine folks here are all subscribed to the thread. You don't need to ping all of us for every question.

@v-mohithgc
Copy link
Contributor

The new version of this task is out, which will fix the issue. please check and confirm back. Thanks

@DevTestUser123
Copy link

No still not working on self hosted agent.

@v-mohithgc
Copy link
Contributor

No still not working on self hosted agent.

What is the task version picked up by your agent?

@DevTestUser123
Copy link

DevTestUser123 commented Apr 17, 2024

6.238.9

No still not working on self hosted agent.

What is the task version picked up by your agent?

@v-mohithgc
Copy link
Contributor

v-mohithgc commented Apr 17, 2024

6.238.9

No still not working on self hosted agent.

What is the task version picked up by your agent?

Many users have confirmed that the new version of the task is working fine (in both Microsoft and self hosted agents), I suspect your error might be a different issue, mostly to do with your pipeline configurations.
If possible, send the debug logs to v-mohithgc@microsoft.com

@rdumitru
Copy link

New version just dropped for us, but it's failing with this error:
Failed to perform Auto-login: PSContextCredentialexec: "pwsh": executable file not found in %PATH%.

@v-snalawade
Copy link
Contributor

New version just dropped for us, but it's failing with this error: Failed to perform Auto-login: PSContextCredentialexec: "pwsh": executable file not found in %PATH%.

what is powershell version installed?

@cyclelabs-ryanberger
Copy link

cyclelabs-ryanberger commented Apr 23, 2024

We are also still receiving this error on a self-hosted Windows 2019 Server based image. Any ideas on how to resolve? We are using a WIF for our Azure DevOps Service connection for this task. This was part of why we upgraded to version 6.

PowerShell Version: 5.1.14393.5582
AzFileCopy Version: 6.238.9

`Starting: AzureFileCopy
==============================================================================
Task         : Azure file copy
Description  : Copy files to Azure Blob Storage or virtual machines
Version      : 6.238.9
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
==============================================================================
Added TLS 1.2 in session.
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Accounts\2.17.0\Az.Accounts.psd1 -Global
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount System.Collections.Hashtable

Set-AzContext System.Collections.Hashtable
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Resources\6.16.1\Az.Resources.psd1 -Global
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Storage\6.1.3\Az.Storage.psd1 -Global
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Compute\7.2.0\Az.Compute.psd1 -Global
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Network\7.4.1\Az.Network.psd1 -Global
##[warning]The names of some imported commands from the module 'Microsoft.Azure.PowerShell.Cmdlets.Network' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
##[warning]The names of some imported commands from the module 'Az.Network' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
 mime: C:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\6.238.9\MimeMapping.json
Account                              SubscriptionName TenantId                             Environment
-------                              ---------------- --------                             -----------
REDACTED AZURE TENANT/SUBSCRIPTION

Uploading files from source path: 'C:\a\1\s\*.exe' to storage account: 'REDACTED' in container: 'REDACTED' with blob prefix: 'REDACTED-2-buildPipeline-20240423.7'
 & "AzCopy\AzCopy.exe" copy "C:\a\1\s\*.exe" "[REDACTED"](REDACTED)  --log-level=INFO --recursive
INFO: Scanning...

Failed to perform Auto-login: PSContextCredentialexec: "pwsh": executable file not found in %PATH%.`

@DevTestUser123
Copy link

DevTestUser123 commented Apr 26, 2024

Which is the required PowerShell version to use so that I cant get an error?

@imerzan
Copy link

imerzan commented Apr 27, 2024

Also getting the error

Failed to perform Auto-login: PSContextCredentialexec: "pwsh": executable file not found in %PATH%.`

Switching to version 5 works (I had to do this first https://stackoverflow.com/questions/52769758/azure-blob-storage-authorization-permission-mismatch-error-for-get-request-wit )

@DevTestUser123
Copy link

DevTestUser123 commented Apr 28, 2024

Also getting the error

Failed to perform Auto-login: PSContextCredentialexec: "pwsh": executable file not found in %PATH%.`

Switching to version 5 works (I had to do this first https://stackoverflow.com/questions/52769758/azure-blob-storage-authorization-permission-mismatch-error-for-get-request-wit )

I am already using version 5 still didn't work for me, also gave required storage permission

@cyclelabs-ryanberger
Copy link

cyclelabs-ryanberger commented Apr 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Release Area:RM RM task team bug p1 Priority 1 (should have immediate attention) regression This used to work, but a change in the service/tasks broke it.
Projects
None yet
Development

No branches or pull requests

8 participants