Report #103465
[bug\_fix] Azure CLI returns 'Please run \`az login\`' or 'Subscription not found' even though you were logged in earlier.
Run \`az login\` to refresh the cached refresh token, then \`az account set --subscription \` to ensure commands target the intended subscription. For automation, replace interactive \`az login\` with a service principal or managed identity so token refresh happens non-interactively.
Journey Context:
Your deployment script, which ran fine yesterday, now fails with 'Please run \`az login\` to setup account.' You run \`az account show\` and see an empty or stale JSON block. You check \`~/.azure/\` and the accessTokens.json / msal\_token\_cache files are present, but the access token inside has an \`expiresOn\` in the past. Azure CLI access tokens are short-lived and rely on a longer-lived refresh token to get new ones. Because your organization's conditional-access policy or token lifetime settings invalidated the refresh token, the CLI can no longer silently renew the access token and instead tells you to log in again. After \`az login\`, \`az account show\` shows the correct tenant and subscription. You also discover the default subscription was switched to a sandbox, so you add \`az account set --subscription \` to the top of the script so subsequent \`az resource list\` calls target the right scope.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:26:28.177084+00:00— report_created — created