azure-pipelines-tasks: [BUG]: AzureFileCopy@6 Auto-login with Powershell context fails

New issue checklist

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)

Most upvoted comments

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:

export AZCOPY_AUTO_LOGIN_TYPE=AZCLI
export AZCOPY_TENANT_ID=$tenantId
azcopy cp "/path/to/dir" "https://[account].blob.core.windows.net/[container]/[path/to/directory]" --recursive=true

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:

- task: AzureCLI@2
  displayName: 'Upload static website to  container'
  inputs:
    azureSubscription: 'MyServiceConnection'   
    scriptType: 'ps'                           
    scriptLocation: 'inlineScript'
    inlineScript: |
      az storage blob upload-batch `
        --account-name $(storageAccountName) `
        --source "$(Build.ArtifactStagingDirectory)" `
        --destination '$folder' `
        --auth-mode login `
        --overwrite true

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

  • task: AzureFileCopy@6 how do I specify the version? thanks

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

- task: PowerShell@2
  displayName: 'Download and Use AzCopy'
  inputs:
    targetType: 'inline'
    script: |
      Invoke-WebRequest -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile "azcopy.zip"
      Expand-Archive -Path "azcopy.zip" -DestinationPath "azcopy"
      $azCopyExe = Get-ChildItem -Recurse -Path "azcopy" -Filter "azcopy.exe" | Select-Object -First 1

      & $azCopyExe.FullName login --identity
      & $azCopyExe.FullName copy "{sourcefile}" `
                                  "{destinationContainer}" `
                                  --recursive --log-level=INFO

updated self-hosted agent version to latest, updated Az Modules to latest

2025-06-16T16:04:01.4094554Z Task         : Azure file copy
2025-06-16T16:04:01.4094653Z Description  : Copy files to Azure Blob Storage or virtual machines
2025-06-16T16:04:01.4094768Z Version      : 6.258.2
...
2025-06-18T14:35:04.7486388Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Resources\8.0.0\Az.Resources.psd1 -Global
2025-06-18T14:35:13.9249352Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Storage\9.0.0\Az.Storage.psd1 -Global
2025-06-18T14:35:15.6039390Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Compute\10.0.1\Az.Compute.psd1 -Global
2025-06-18T14:35:18.6206050Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Network\7.17.0\Az.Network.psd1 -Global
...
2025-06-16T16:05:47.9357332Z Failed to perform Auto-login: PSContextCredential‌Get-AzAccessToken: -REDACTED-;1mA parameter cannot be found that matches parameter name AsSecureString.‌

The same for me. Az PS 14.1.0

@rm-dmiri

Task         : Azure file copy
Description  : Copy files to Azure Blob Storage or virtual machines
Version      : 6.258.2
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy

Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\5.1.0\Az.Accounts.psd1 -Global
Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Resources\8.0.0\Az.Resources.psd1 -Global
Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Storage\9.0.0\Az.Storage.psd1 -Global
Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Compute\10.0.1\Az.Compute.psd1 -Global
Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Network\7.17.0\Az.Network.psd1 -Global

INFO: Scanning...

Failed to perform Auto-login: PSContextCredentialGet-AzAccessToken: -REDACTED-;1mRun Connect-AzAccount to login.

updated self-hosted agent version to latest, updated Az Modules to latest

2025-06-16T16:04:01.4094554Z Task         : Azure file copy
2025-06-16T16:04:01.4094653Z Description  : Copy files to Azure Blob Storage or virtual machines
2025-06-16T16:04:01.4094768Z Version      : 6.258.2
...
2025-06-18T14:35:04.7486388Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Resources\8.0.0\Az.Resources.psd1 -Global
2025-06-18T14:35:13.9249352Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Storage\9.0.0\Az.Storage.psd1 -Global
2025-06-18T14:35:15.6039390Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Compute\10.0.1\Az.Compute.psd1 -Global
2025-06-18T14:35:18.6206050Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Network\7.17.0\Az.Network.psd1 -Global
...
2025-06-16T16:05:47.9357332Z Failed to perform Auto-login: PSContextCredential‌Get-AzAccessToken: -REDACTED-;1mA parameter cannot be found that matches parameter name AsSecureString.‌

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.

+1 got the same issue on Microsoft Hosted agent pipelines.

We were using windows-latest agents, but swapping to windows-2025 seems to have worked as a workaround for now!

This issue should be the highest priority though considering the amount of users it’s affecting

(I’ll also prefice that we use this job in the Release pipeline, and not the Build pipeline - so this may effect whether the workaround works for you or not)

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…

This issue hit our pipelines today. We are trying the workaround proposed by RikardSchouwstra, however if this doesn’t work it brings a critical project to a grinding halt.

@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.