- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.7k
Description
New issue checklist
- I searched for existing GitHub issues
- I read pipeline troubleshooting guide
- I checked how to collect logs
Task name
azure-file-copy-v6
Task version
v6
Issue Description
Same as 19876, not resolved.
https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/azure-file-copy-v6
Issues:
When using the AzureFileCopy@6 task to copy files to an Azure VM, the following preparation are necessary on the target VM in advance. These requirements are not mentioned on the AzureFileCopy@6 documentation page:
Installation of PowerShell Core (pwsh).
Installation of the Az module.
Enabling the system-assigned managed identity and signing in using Connect-AzAccount -Identity.
If pwsh is not installed in the target VM, the following error occurs:
Failed to perform Auto-login: PSContextCredentialexec: "pwsh": executable file not found in %PATH%.
Additionally, if the Az module is not installed in the target VM, the following error occurs:
Failed to perform Auto-login: PSContextCredential;Get-AzAccessToken: -REDACTED-;The term 'Get-AzAccessToken' is not recognized as a name of a cmdlet, function, script file, or executable program.
Then, Connect-AzAccount is not executed manually on the target VM, the following error occurs:
Failed to perform Auto-login: PSContextCredential;Get-AzAccessToken: -REDACTED-;Run Connect-AzAccount to login.
Cause of the third issue:
According to the document for AzCopy, "AZCOPY_AUTO_LOGIN_TYPE" environment variable can be used for auto-login. In the AzureFileCopy@6 task, this is set to "PSCRED" at the following step.
| $env:AZCOPY_AUTO_LOGIN_TYPE = "PSCRED" | 
In this case, AzCopy tries to get token by Get-AzAccessToken, but no Connect-AzAccount is called in this session, so the error occurs.
For your information, I added a "PowerShell on Target machine" task to run "Connect-AzAccount -Identity -Scope CurrentUser" to the pipeline so that I could avoid running it manually in RDP session, but no luck. The pipeline failed with the same error. Only manual run of Connect-AzAccount is the current workaround.
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)
Operation system
Relevant log output
-Full task logs with system.debug enabled
[REPLACE THIS WITH YOUR INFORMATION]