Azure / Azure/azure-cli

az acr login regression in 2.87.0 on AzureML compute MSI/SSO

Open
#33,698 4 comments 1 reaction 2 assignees Claimed by @a0x1ab View on GitHub
AAD Account act-observability-squad ARM Auto-Assign bug Container Registry customer-reported Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

# az acr login regression in 2.87.0 on AzureML compute MSI/SSO

## Summary

`az acr login` appears to regress between Azure CLI 2.81.0 and 2.87.0 on an AzureML Compute
Instance using `az login --identity`.

On the same AzureML compute instance, Azure CLI 2.81.0 succeeds with `az acr login`, while
Azure CLI 2.87.0 fails. A direct ACR OAuth `/oauth2/exchange` using the ARM access token succeeds,
so this does not appear to be an ACR RBAC issue.

## Repro commands

```bash
az login --identity
az acr login -n $ACR
```

## Observed behavior with Azure CLI 2.87.0

```text
az account get-access-token --resource https://management.azure.com/
=> succeeds

az account get-access-token --resource https://containerregistry.azure.net
=> fails:
ERROR: {'error': 'SSO failure, to mitigated it please try to click Jupyter/JupyterLab.'}
Run the command below to authenticate interactively; additional arguments may be added as needed:
az logout
az login

az acr login -n $ACR--expose-token
=> fails:
WARNING: Unable to get AAD authorization tokens with message: {'error': 'SSO failure, to mitigated it please try to click Jupyter/JupyterLab.'}
WARNING: Unable to get admin user credentials with message: Admin user is disabled.
ERROR: Unable to authenticate using AAD or admin login credentials. Please specify both username and password in non-interactive mode.

az acr login -n $ACR
=> fails with the same warnings/errors
```

## Expected behavior / behavior with Azure CLI 2.81.0

```text
az account get-access-token --resource https://containerregistry.azure.net
=> fails with the same SSO error

az acr login -n $ACR --expose-token
=> succeeds and returns an accessToken

az acr login -n amlacraepije663sbqi
=> Login Succeeded
```

Installing Azure CLI 2.81.0 into an isolated venv on the same machine makes `az acr login` work:

```bash
python -m venv ~/azcli-2.81-test
source ~/azcli-2.81-test/bin/activate
pip install 'azure-cli==2.81.0'
az login --identity
az acr login -n $ACR --expose-token
az acr login -n $ACR
```

## Additional evidence

A direct ACR OAuth exchange using the ARM access token succeeds on the failing Azure CLI 2.87.0
machine:

```text
ARM token: ok
ACR OAuth exchange with ARM token: {"exchange": "ok", "has_refresh_token": true}
```

The direct exchange is:

```http
POST https://$ACR.azurecr.io/oauth2/exchange

grant_type=access_token
service=$ACR.azurecr.io
tenant=
access_token=
```

Using the returned refresh token with Docker succeeds:

```bash
printf '%s' "$REFRESH_TOKEN" | docker login $ACR.azurecr.io \
-u 00000000-0000-0000-0000-000000000000 \
--password-stdin
```

Result:

```text
Login Succeeded
```

This suggests ACR authorization and registry-side OAuth exchange are working, but the Azure CLI
2.87.0 `az acr login` implementation is not using, or is no longer falling back to, the ARM-token
exchange path that works in Azure CLI 2.81.0.

## Suspected regression area

Likely area: built-in ACR command module / auth path used by `az acr login`.

The ACR module files differ between working 2.81.0 and failing 2.87.0 installations:

```text
azure.cli.command_modules.acr custom.py: different SHA256
azure.cli.command_modules.acr _docker_utils.py: different SHA256
azure.cli.command_modules.acr _constants.py: different SHA256
```

The suspected behavior change is in how `az acr login` chooses between:

1. acquiring an AAD token for `https://containerregistry.azure.net`, and
2. exchanging an ARM token at `https:///oauth2/exchange`.

In this AzureML MSI/SSO environment, path (1) fails but path (2) succeeds. Azure CLI 2.81.0 still
logs in successfully; Azure CLI 2.87.0 fails.

### Related command

az login --identity
az acr login -n $ACR

### Errors

ERROR: {'error': 'SSO failure, to mitigated it please try to click Jupyter/JupyterLab.'}
Run the command below to authenticate interactively; additional arguments may be added as needed:
az logout
az login

### Issue script & Debug output

(azureml_py38) azureuser@elonp2:~/repos/kblam/collabs/ct/image$ az acr login -n $ACR --debug
cli.knack.cli: Command arguments: ['acr', 'login', '-n', 'amlacraepije663sbqi', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Using packaged command index for profile 'latest'.
cli.azure.cli.core: Found installed extension 'azure-cli-ml' (azext_ml).
cli.azure.cli.core: Blending packaged core index with local extension index.
cli.azure.cli.core: Modules found from index for 'acr': ['azure.cli.command_modules.acr']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Loaded command modules in parallel:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acr 0.055 36 150
cli.azure.cli.core: Total (1) 0.057 36 150
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 36 groups, 150 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : acr login
cli.azure.cli.core: Command table: acr login
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/azureuser/.azure/commands/2026-07-03.10-41-21.acr_login.85242.log'.
az_command_data_logger: command args: acr login -n {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7ba1d7179d80>]
cli.knack.commands: Configured default 'eyeson.heron.prod.e02fd9de-d296-41d1-bd86-efc4853e27da' for arg resource_group_name
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7ba1d71a16c0>, .add_global_policy_argument at 0x7ba1d71a17e0>, .add_cache_arguments at 0x7ba1d71a1870>, .update_breaking_change_info at 0x7ba1d71a1900>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x7ba1d71a1750>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ContainerRegistryManagementClient
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token_info: scopes=('https://management.core.windows.net//.default',), options={}
cli.azure.cli.core.auth.msal_credentials: ManagedIdentityCredential.acquire_token: scopes=['https://management.core.windows.net//.default'], kwargs={}
msal.managed_identity: Obtaining token via managed identity on Azure Machine Learning
urllib3.connectionpool: Starting new HTTP connection (1): 127.0.0.1:46808
urllib3.connectionpool: http://127.0.0.1:46808 "GET /MSI/auth?api-version=2017-09-01&resource=https%3A%2F%2Fmanagement.core.windows.net%2F HTTP/1.1" 200 None
msal.token_cache: event={
"client_id": null,
"data": {},
"params": {},
"response": {
"access_token": "********",
"expires_in": 2867,
"resource": "https://management.core.windows.net/",
"token_type": "Bearer"
},
"scope": [
"https://management.core.windows.net/"
],
"token_endpoint": "https://localhost/managed_identity"
}
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/08047947-f71e-4462-a09d-266e3d34c431/resourceGroups/eyeson.heron.prod.e02fd9de-d296-41d1-bd86-efc4853e27da/providers/Microsoft.ContainerRegistry/registries/amlacraepije663sbqi?api-version=2026-01-01-preview'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'bb55ace4-76cb-11f1-b4c5-0022480137ed'
cli.azure.cli.core.sdk.policies: 'CommandName': 'acr login'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.87.0 (PIP) azsdk-python-core/1.39.0 Python/3.10.0 (Linux-6.8.0-1059-azure-x86_64-with-glibc2.35)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/08047947-f71e-4462-a09d-266e3d34c431/resourceGroups/eyeson.heron.prod.e02fd9de-d296-41d1-bd86-efc4853e27da/providers/Microsoft.ContainerRegistry/registries/amlacraepije663sbqi?api-version=2026-01-01-preview HTTP/1.1" 200 1582
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '1582'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'api-supported-versions': '2026-01-01-preview'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-reads': '1099'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-reads': '16499'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'f8a0723f-70ae-4a26-bc44-4ac3a78c7de0'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'f8a0723f-70ae-4a26-bc44-4ac3a78c7de0'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'EASTUS2:20260703T104122Z:f8a0723f-70ae-4a26-bc44-4ac3a78c7de0'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: 9539786F689A4F4E9D71A27E71C381D3 Ref B: AMS231032609053 Ref C: 2026-07-03T10:41:22Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Fri, 03 Jul 2026 10:41:22 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"sku":{"name":"Basic","tier":"Basic"},"type":"Microsoft.ContainerRegistry/registries","id":"/subscriptions/08047947-f71e-4462-a09d-266e3d34c431/resourceGroups/EYESON.HERON.PROD.e02fd9de-d296-41d1-bd86-efc4853e27da/providers/Microsoft.ContainerRegistry/registries/amlacraepije663sbqi","name":"amlacraepije663sbqi","location":"eastus2","tags":{},"systemData":{"createdBy":"54caada3-19bd-4b50-9eb8-70f6f6d4b32e","createdByType":"Application","createdAt":"2026-02-04T19:59:01.9248036+00:00","lastModifiedBy":"54caada3-19bd-4b50-9eb8-70f6f6d4b32e","lastModifiedByType":"Application","lastModifiedAt":"2026-06-18T03:53:06.5129871+00:00"},"properties":{"loginServer":"amlacraepije663sbqi.azurecr.io","creationDate":"2026-02-04T19:59:01.9248036Z","provisioningState":"Succeeded","adminUserEnabled":false,"policies":{"quarantinePolicy":{"status":"disabled"},"trustPolicy":{"type":"Notary","status":"disabled"},"retentionPolicy":{"days":7,"status":"disabled"},"exportPolicy":{"status":"enabled"},"azureADAuthenticationAsArmPolicy":{"status":"enabled"},"softDeletePolicy":{"retentionDays":7,"status":"disabled"}},"encryption":{"status":"disabled"},"dataEndpointEnabled":false,"regionalEndpoints":"Disabled","dataEndpointHostNames":[],"regionalEndpointHostNames":[],"endpointProtocol":"IPv4","privateEndpointConnections":[],"publicNetworkAccess":"Enabled","networkRuleBypassOptions":"AzureServices","networkRuleBypassAllowedForTasks":false,"zoneRedundancy":"Disabled","metadataSearch":"Disabled","roleAssignmentMode":"LegacyRegistryPermissions","autoGeneratedDomainNameLabelScope":"Unsecure"}}
cli.azure.cli.command_modules.acr._docker_utils: 2026-07-03 10:41:22.495061 Sending a HTTP Get request to https://amlacraepije663sbqi.azurecr.io/v2/
urllib3.connectionpool: Starting new HTTPS connection (1): amlacraepije663sbqi.azurecr.io:443
urllib3.connectionpool: https://amlacraepije663sbqi.azurecr.io:443 "GET /v2/ HTTP/1.1" 401 149
cli.azure.cli.command_modules.acr._docker_utils: Attempting to retrieve AAD refresh token...
cli.azure.cli.command_modules.acr._docker_utils: 2026-07-03 10:41:22.770695 Sending a HTTP Get request to https://amlacraepije663sbqi.azurecr.io/v2/
urllib3.connectionpool: Starting new HTTPS connection (1): amlacraepije663sbqi.azurecr.io:443
urllib3.connectionpool: https://amlacraepije663sbqi.azurecr.io:443 "GET /v2/ HTTP/1.1" 401 149
cli.azure.cli.core.auth.msal_credentials: ManagedIdentityCredential.acquire_token: scopes=['https://containerregistry.azure.net/.default'], kwargs={}
msal.managed_identity: Obtaining token via managed identity on Azure Machine Learning
urllib3.connectionpool: Starting new HTTP connection (1): 127.0.0.1:46808
urllib3.connectionpool: http://127.0.0.1:46808 "GET /MSI/auth?api-version=2017-09-01&resource=https%3A%2F%2Fcontainerregistry.azure.net HTTP/1.1" 404 80
cli.azure.cli.core.auth.util: MSAL error: {'error': 'invalid_scope', 'error_description': "{'error': 'SSO failure, to mitigated it please try to click Jupyter/JupyterLab.'}"}
cli.azure.cli.command_modules.acr._docker_utils: Unable to get AAD authorization tokens with message: {'error': 'SSO failure, to mitigated it please try to click Jupyter/JupyterLab.'}
cli.azure.cli.command_modules.acr._docker_utils: Unable to get admin user credentials with message: Admin user is disabled.
Username:

### Expected behavior

`az acr login -n $ACR` should succeed in logging-in to the ACR.

### Environment Summary

azure-cli 2.87.0

core 2.87.0
telemetry 1.1.0

Extensions:
azure-cli-ml 1.41.0
ml 2.43.0

Dependencies:
msal 1.36.0
azure-mgmt-resource 24.0.0

Python location '/anaconda/envs/azureml_py38/bin/python'
Config directory '/home/azureuser/.azure'
Extensions directory '/opt/az/extensions'

Python (Linux) 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:24:10) [GCC 9.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

Compute instance software version
Linux 26.06.15 (current)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.