Skip to content

AzureCLICredential: Windows shell quoting bug when passing subscription ID #25492

@EronWright

Description

@EronWright

Bug Report

Describe the bug

AzureCLICredential fails on Windows when a subscription ID is passed via AzureCLICredentialOptions.Subscription. The subscription ID gets wrapped in literal quotes, causing authentication to fail with: ERROR: Subscription '"UUID"' not found

Reproduction

Environment: Windows 10/11, any Go version, azidentity v1.11.0

Code:

options := &azidentity.AzureCLICredentialOptions{
    Subscription: "12345678-1234-1234-1234-123456789abc",
}
cred, _ := azidentity.NewAzureCLICredential(options)
token, err := cred.GetToken(context.Background(), /* ... */)
// Fails with: Subscription '"12345678-1234-1234-1234-123456789abc"' not found

Expected: Successfully authenticate using the specified subscription.

Actual: Error includes literal quote characters around the UUID.

Root Cause

The command string passed to cmd.exe /c in developer_credential_util.go includes escaped quotes (\") that Windows interprets as literal characters rather than string delimiters. Unix shells handle this correctly, so the issue only affects Windows.

Command built in azure_cli_credential.go:

command += ` --subscription "` + c.opts.Subscription + `"`

Executed as:

cmd.exe /c "az account get-access-token ... --subscription \"UUID\""

Impact

Affects Windows users who explicitly set a non-default subscription in AzureCLICredentialOptions. Authentication fails entirely for these users.

Additional Context

Metadata

Metadata

Assignees

Labels

Azure.Identitycustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

Projects

Status

In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions