Skip to content

[BUG]: AzureFileCopy@6 Auto-login with Powershell context fails #21053

@shadowCow

Description

@shadowCow

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.

"url": "https://vstsagenttools.blob.core.windows.net/tools/azcopy/10.25.1/AzCopy.zip",

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)"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions