azure-pipelines-tasks: [BUG]: AzureFileCopy@6 Auto-login with Powershell context fails
New issue checklist
- I searched for existing GitHub issues
- I read pipeline troubleshooting guide
- I checked how to collect logs
Task name
AzureFileCopy
Task version
6.254.0
Issue Description
We are seeing this error when using AzureFileCopy@6 task:
Failed to perform Auto-login: json: cannot unmarshal object into Go struct field .Token of type string.
The prior successful run has this output instead:
INFO: Login with Powershell context succeeded
This error is thrown from AzCopy. https://github.com/Azure/azure-storage-azcopy/blob/7d683d1b22b9d473e5335eed1818d9a563d77a5f/cmd/credentialUtil.go#L131
The failing runs are using Az.Accounts 5+
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Accounts\5.0.1\Az.Accounts.psd1 -Global
The prior successful run used Az.Accounts 4.2.0.
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Accounts\4.2.0\Az.Accounts.psd1 -Global
It looks like Az.Accounts 5.0.0 changed tokens to use SecureString instead of plain text.
AzureFileCopy@6 declares a dependency on AzCopy 10.25.1. https://github.com/microsoft/azure-pipelines-tasks/blob/8a3760fa736f18b880a5c9fe394c06f8db520858/Tasks/AzureFileCopyV6/make.json#L41
AzCopy appears to have addressed the Az.Accounts 5.0.0 change in newer versions. https://github.com/Azure/azure-storage-azcopy/blame/7d683d1b22b9d473e5335eed1818d9a563d77a5f/common/azure_ps_context_credential.go#L140
Hopefully updating the AzureFileCopy@6 dependency on AzCopy to 10.29.0 or 10.29.1 will fix the issue.
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
Starting: redacted
==============================================================================
Task : Azure file copy
Description : Copy files to Azure Blob Storage or virtual machines
Version : 6.254.0
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\5.0.0\Az.Accounts.psd1 -Global
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Update-AzConfig -CheckForUpgrade False -AppliesTo Az -Scope Process
Get-AzConfig -AppliesTo Az
Update-AzConfig -DisplayBreakingChangeWarning False -AppliesTo Az -Scope Process
Enable-AzureRmAlias -Scope Process
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount
Name Value
---- -----
Tenant redacted
Scope Process
Environment AzureCloud
ApplicationId ***
ServicePrincipal True
Key Value Applies To Scope Help Message
--- ----- ---------- ----- ------------
CheckForUpgrade False Az Process When enabled, Azure PowerShell will check for updates automati...
DisplayBreakingChangeWarning False Az Process Controls if warning messages for breaking changes are displaye...
Environments : {[AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud], [AzureUSGovernment, AzureUSGovernment]}
Context : Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext
Set-AzContext
Name Value
---- -----
SubscriptionId redacted
Name : redacted
Subscription : redacted
Account : ***
Environment : AzureCloud
Tenant : redacted
TokenCache :
VersionProfile :
ExtendedProperties : {}
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Resources\8.0.0\Az.Resources.psd1 -Global
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Storage\9.0.0\Az.Storage.psd1 -Global
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Compute\10.0.0\Az.Compute.psd1 -Global
Import-Module -Name C:\Users\AzDevOps\Documents\WindowsPowerShell\Modules\Az.Network\7.16.2\Az.Network.psd1 -Global
mime: C:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\6.254.0\MimeMapping.json
Uploading files from source path: 'C:\a\1\s\*.exe' to storage account: 'redacted' in container: 'redacted' with blob prefix: 'redacted'
& "AzCopy\AzCopy.exe" copy "C:\a\1\s\*.exe" "redacted" --log-level=INFO --recursive
INFO: Scanning...
Failed to perform Auto-login: json: cannot unmarshal object into Go struct field .Token of type string.
Full task logs with system.debug enabled
[REPLACE THIS WITH YOUR INFORMATION]
Repro steps
trigger:
- none
pool:
vmImage: 'windows-latest'
steps:
- task: AzureFileCopy@6
inputs:
SourcePath: '$(Build.SourcesDirectory)\*.exe'
azureSubscription: "redacted"
Destination: "AzureBlob"
storage: "redacted"
ContainerName: "redacted"
BlobPrefix: "redacted-$(Build.BuildNumber)"
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 27
- Comments: 97 (10 by maintainers)
Thanks for your patience on this issue. The fix has now been deployed— you can find the corresponding pull request here. A new task version has been deployed. To benefit from the fix, please ensure you’re using version 6.258.0 or later of AzureFileCopy task. Consider creating a new release to incorporate the updated task version.
This has been failing for us on about 150 pipelines since Friday evening (westEurope - windows-2022)
A very common Task on its most recent version using normal configuration is broken. I can’t believe how this passed Microsoft testing, and how little Microsoft respond to this 😦
I see the same behavior. Are there any workarounds ?
Not sure working around it by switching to 2019 is a good idea. They are dropping Windows2019 at the end of the month. Hopefully the fix is released before then.
I worked around this by changing to ubuntu agent and using Azure CLI task instead of Azure file copy:
deployment is completed and issue is resolved with upgrading AzCopy.exe to 10.29.1 in AzureFilecopyv6 task.
Fixed on most of our pipelines. Some Azure VMs still missing the update but shjould be coming soon.
+1 same problem but in my case swapping to windows-2025 has not worked 😦
I was able to resolve the issue with Azure CLI using a service principal:
Make sure that your SP has Reader/Contributor or Storage Blob Data Contributor rights on or use account keys instead.
Yup windows-2025 not working.
Hi @tomaustin700 and @erikb-mntc,
Thanks for flagging this! It looks like the issue may stem from a compatibility mismatch between the tools. Could you try upgrading your Az modules to the latest version? You can find more here: 🔗 https://github.com/Azure/azure-powershell/releases/tag/v14.0.0-May2025
Alternatively, if you’re using YAML pipelines, you can manually pin the task to a previous working version as a temporary workaround that @erikb-mntc already mentioned. We will work on restoring backward compatibility in the task. Appreciate your patience and input!
@rm-dmiri sorry if I am missing the obvious but in yml when I use - I am using MS-hosted agents
windows-2025 not working 😦
WORKAROUND: I was able to run it by going back to version 3.* of the task and then setup the variables for Storage Container URI, Storage Container SAS Token and SAS Token Expiration Period In Minutes. i hope it will help you.
We have upgraded AzCopy.exe version to 10.29.1 and creating hotfix deployment.
until the fix is rolled out , for self hosted agents azcopy.exe can be downloaded explicitly and used in powershell task.
https://aka.ms/downloadazcopy-v10-windows downloads version 10.29.1
To work around this until there is a fix we explicitly download the azcopy to our agent, and use it directly. This does mean checks need to be added to ensure it does not already exist on the machine, but in our case work well enough.
https://aka.ms/downloadazcopy-v10-windows downloads version 10.29.1
The same for me. Az PS 14.1.0
@rm-dmiri
updated self-hosted agent version to latest, updated Az Modules to latest
Hi @tomaustin700,
We have worked on implementing backward compatibility for the AzureFileCopyV6 task. The new version (>= 6.258.2) will be deployed starting today, following our normal deployment process. It might take some time to reach all rings, so please keep an eye out for the specific version.
Thank you for your patience.
Okay it appears this work around has stopped working for the given scenario as well now - Microsoft have broken even more use cases
There must be an issue with the task (and the source its downloading to the agent) not the agent env itself - i can replicate the issue appearing with no change to my own docker based agent on windows AND the managed windows-2025. I suspect pre-job for this task to fetch latest azcopy, and there seems a bug with identity auth in that one…
@OTIPCutler We got around this by basically manually writing the file copy task, using the latest
azcopy.exe, with native PowerShell scripting rather than using the task and got around this.