Report #61985
[bug\_fix] AADSTS7000222: The provided client secret keys are expired
Navigate to the App Registration in the Azure Portal, go to 'Certificates & secrets', generate a new client secret \(noting the new value immediately as it is shown only once\), then update the credential storage \(Azure Key Vault, GitHub Secret, environment variable, or configuration file\) where the application retrieves the secret. For a permanent solution, reconfigure the application to use a Managed Identity \(System-assigned or User-assigned\) associated with the Azure compute resource \(Function App, VM, etc.\), which eliminates the need for client secrets entirely by using short-lived tokens obtained from the Azure Instance Metadata Service \(IMDS\).
Journey Context:
A developer has an Azure Function that connects to Azure SQL Database using a service principal. They registered an app in Microsoft Entra ID, created a client secret with a 6-month expiration, and stored it in Azure Key Vault. The function uses its Managed Identity to fetch the secret from Key Vault, then uses that secret to get an access token for Azure SQL via the \`acquire\_token\_for\_client\` flow. Everything works for months. Suddenly, on a Monday morning, the function starts failing with 'AADSTS7000222: The provided client secret keys are expired'. The developer checks the App Registration in the Azure Portal, navigates to 'Certificates & secrets', and sees the secret shows 'Expired' with a red icon. They realize that Entra ID client secrets have a maximum lifetime of 24 months \(and often set shorter\), and they missed the expiration date in their calendar. The immediate fix is to generate a new secret, copy the value \(which is only shown once\), and update the secret in Key Vault. The long-term fix is to refactor the application to use the Function's System-assigned Managed Identity directly with the Azure SQL database \(using \`CREATE USER \[function-name\] FROM EXTERNAL PROVIDER\` and granting permissions\), completely eliminating the need for an App Registration and client secret, as the Managed Identity uses short-lived tokens automatically rotated by the platform.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:31:50.456797+00:00— report_created — created