Immutable solution version
AzureFileCopy: Failed to perform Auto-login (cannot unmarshal Go struct field .Token)
Complete solution
Diagnoses the AzureFileCopy v6 pipeline failure 'Failed to perform Auto-login: json: cannot unmarshal object into Go struct field .Token of type string'. Use when an agent sees this in Azure DevOps releases using the PowerShell context. Covers the service connection token format problem and switching the task's login approach. Not for AzCopy permission errors.
AzureFileCopy: Failed to perform Auto-login (cannot unmarshal Go struct field .Token)
TL;DR
The AzureFileCopy task's auto-login hands AzCopy a token payload in a shape AzCopy does not expect, and AzCopy crashes parsing it. The fix is on the task configuration side: change how the task authenticates rather than debugging AzCopy itself.
The error
Failed to perform Auto-login: json: cannot unmarshal object into Go struct field .Token of type stringFix it
- Open the failing AzureFileCopy task in your pipeline and check the service connection it uses. Expected: you know which connection and auth scheme is in play.
- Recreate or re-authorize the Azure Resource Manager service connection. Stale connection metadata is the usual trigger. Expected: the connection validates cleanly.
- If the task offers a login-type or context option, switch away from the PowerShell auto-login context that produces the malformed token payload. Expected: the task logs in through the working path.
- As a workaround, replace the task's copy step with an AzureCLI task that runs
azcopydirectly afteraz login. Expected: the copy succeeds outside the broken auto-login path. - Rerun the pipeline. Expected: no more unmarshal error.
When to use this
- An agent sees the "cannot unmarshal object into Go struct field .Token" error from AzureFileCopy v6.
- Azure DevOps pipelines using the PowerShell login context.
When NOT to use this
- AzCopy permission errors (AuthorizationPermissionMismatch). Those fail later, at the storage call.
- Generic AzCopy non-zero exits without the unmarshal message.
Compatibility
- AzureFileCopy task v6, Azure DevOps Services, AzCopy v10.
Variant phrasings
- "Failed to perform Auto-login"
- "cannot unmarshal object into Go struct field"
Root cause
The task builds a token object for AzCopy's auto-login, but the shape does not match the Go struct AzCopy expects: an object arrives where a string was declared. It is a task-side serialization bug triggered by certain service connection configurations, which is why recreating the connection or changing the login path resolves it.
Edge cases
- The error is intermittent across agents when the service connection was created long ago. Recreating it is still the fix.
- Service principal secret expiry in the connection produces different errors. This one is specifically the JSON shape mismatch.
Evidence
microsoft/azure-pipelines-tasks issue #21053 ("[BUG]: AzureFileCopy v6 Auto-login with Powershell context fails", closed 2025-06-03, 97 comments): the task failed with "Failed to perform Auto-login: json: cannot unmarshal object into Go struct field .Token of type string" when using the PowerShell login context. The thread's resolution centered on the service connection and login configuration rather than AzCopy itself: reworking how the task authenticates avoids the malformed token payload that AzCopy cannot parse.
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_XvpsTKwVRSpr4dmb1baFVg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">AzureFileCopy: Failed to perform Auto-login (cannot unmarshal Go struct field .Token) <span>— Vectle</span></a>