What breaks
A client secret can be added to an enterprise application's service principal instead of its app registration, with servicePrincipal: addPassword. When that secret expires, token requests that use it fail with AADSTS7000222 until the workload has a replacement. Microsoft's error reference describes it as "The provided client secret keys are expired."
How you notice
These secrets belong to the service principal, so App registrations > Certificates & secrets does not list them. A workload's failed sign-in is often the first sign.
How do I find enterprise app secrets that expire soon?
Read service principal passwordCredentials and compare each credential's endDateTime with your lead time. Run this snippet in an authenticated Microsoft Graph PowerShell session:
$WarningDays = 30
$Cutoff = [DateTimeOffset]::UtcNow.AddDays($WarningDays)
Get-MgServicePrincipal -All -Property @('id', 'displayName', 'passwordCredentials') -ErrorAction Stop |
ForEach-Object {
$App = $_
foreach ($Credential in $App.PasswordCredentials) {
if ($null -eq $Credential.EndDateTime) { continue }
$End = [DateTimeOffset][DateTime]::SpecifyKind($Credential.EndDateTime, 'Utc')
if ($End -le $Cutoff) {
[pscustomobject]@{
App = $App.DisplayName
ServicePrincipalId = $App.Id
KeyId = $Credential.KeyId
EndDateTime = $End.UtcDateTime.ToString('o')
}
}
}
}
A SAML signing certificate created in Entra comes with a password credential that shares the signing key's key ID, as Microsoft's SAML single sign-on configuration guide shows. Renew that one with the SAML signing certificate guide, not as a separate secret.
Why it happens
Every secret has an expiry date. Creating a replacement does not update the workloads that use the old secret, so each consumer needs its own change.
Renewal path
Create a replacement, update every consumer, verify the new key ID, then remove the old secret. AppAlert only reads credential metadata; it does not create or remove secrets.
The commands follow Microsoft's documentation and were not run against a real environment. Find the service principal object ID in the Microsoft Entra admin center under Enterprise applications, then use Microsoft Graph or Microsoft Graph PowerShell. Check each API reference for the permissions it requires.
Add a replacement
Call addPassword on the service principal. Replace <expiry-utc> with your chosen expiry in ISO 8601 format, and send the request through a client that does not log the response body:
POST https://graph.microsoft.com/v1.0/servicePrincipals/<sp-object-id>/addPassword
Content-Type: application/json
{
"passwordCredential": {
"displayName": "rotation",
"endDateTime": "<expiry-utc>"
}
}
Or use Add-MgServicePrincipalPassword:
$NewCredential = Add-MgServicePrincipalPassword `
-ServicePrincipalId '<sp-object-id>' `
-PasswordCredential @{
displayName = 'rotation'
endDateTime = (Get-Date).AddMonths(6)
} -ErrorAction Stop
# Write $NewCredential.SecretText to the approved secret store without logging it,
# then clear the variable. Do not output $NewCredential.
Remove-Variable NewCredential
Graph returns secretText only when the secret is created. You cannot retrieve it later.
If addPassword is rejected, check the app instance property lock:
- It locks service principal
passwordCredentialsandkeyCredentialswith usageVerify, which Microsoft links to the client credentials flow, and those with usageSign. - Microsoft has turned the lock on by default for new applications since June 2026. Reading existing secrets is not affected.
- The lock is set on the app registration. As at least a Cloud Application Administrator, open App registrations, select the app, then Authentication, and select Configure under App instance property lock.
Unlock only what the rotation needs and turn it back on afterward. See Microsoft's app instance property lock guide and the servicePrincipalLockConfiguration reference.
Update and verify every consumer
Update each consumer to read the replacement from the secret store, deploy, and test a fresh sign-in. Follow Identify the active credential to confirm the new key ID before removing the old one.
Remove the old secret by key ID
Call removePassword with the old key ID:
POST https://graph.microsoft.com/v1.0/servicePrincipals/<sp-object-id>/removePassword
Content-Type: application/json
{
"keyId": "<old-key-id>"
}
Or use Remove-MgServicePrincipalPassword with the same key ID.
Who should own it
Assign the enterprise application's owner to coordinate with the team that deploys the workload. Record an alternate who can cover absences.
Lead time and business-day math
Suggested planning buffer: 30 calendar days. If the app instance property lock blocks addPassword, include time for a Cloud Application Administrator to unlock it. Fit that and each consumer's deployment around weekends, holidays, approvals, and deployment freezes.
Related failure modes
A client secret on an app registration has the same rotation steps through the application instead of the service principal. Use Owner has left and Ownerless credential when renewal has no reachable owner.
Monitored by AppAlert
Monitored
AppAlert monitors the expiry of secrets added to enterprise applications and sends email alerts to configured admin recipients before a secret expires, with optional routing to enterprise application owners.
Expiration tracking does not replace credential rotation or deployment testing.
Use the Operations queue to review the expiry and enterprise application context. Configure who receives alerts in Alert settings and recipients; for a missing alert, follow Missing notifications.