Rotate an app registration's client secret

Azure Portal, Hands On10 minutesFreeSteps checked 13 November 2026By Cloud Hands On

In this task you'll replace an app registration's client secret before it expires.

An app that signs in as itself (not as a person) proves who it is with a client secret (a password), a certificate, or a federated credential (trust in another identity provider, such as GitHub). Secrets and certificates expire, and when they do, the app stops working.

Rotating means: add a new credential, update the app to use it, check it works, then delete the old one. Better still, replace secrets with a managed identity or a federated credential, which have nothing to leak or expire.

Example. SS Kaiser's nightly reports job stops at 02:00 with error AADSTS7000222: the client secret has expired. The fix takes ten minutes; the follow-up moves the job to a managed identity so it can't happen again.

Before you start

You need: Application Administrator, or owner of the app registration. Time: 10 minutes.

Where to look

  1. Home
  2. Microsoft Entra ID
  3. App registrations
  4. (the app)
  5. Certificates & secrets

Steps

  1. Open Microsoft Entra ID, then App registrations, and select the app (you may need the All applications tab).
  2. Open Certificates & secrets. The Client secrets tab lists each secret with its expiry date; one that expires soon has a warning icon.
  3. Select + New client secret. Give it a description; Expires starts on Recommended: 180 days (6 months). Select Add.
  4. Copy the Value straight away and put it where the app reads it, ideally a key vault.It's shown only once. If you leave the page, you'll need another new secret.
  5. After the app is working with the new secret, select the bin icon next to the old one to delete it.
  6. Open Owners and check that at least one current person owns the app, so the next expiry warning reaches someone.

Commands

# Add a new secret valid for 6 months, keeping the old ones (--append)
az ad app credential reset --id <app-id> --append --years 0.5 --display-name rotated --query password -o tsv

# List secrets and when they expire
az ad app credential list --id <app-id> --query "[].{name:displayName, ends:endDateTime, id:keyId}" -o table

Watch out for

Cost
Free.
Security
Never paste secrets into tickets, chat or code. Prefer managed identities (for Azure resources) or federated credentials (for pipelines).
Common mistakes
Deleting the old secret before the app uses the new one, or creating a secret that never expires.

Clean up

Delete any secret you created only to practise.

Words to know

Client secret
A password belonging to an app.
Certificate credential
A public key uploaded to the app; the app proves itself with the private key.
Federated credential
Lets the app swap a token from another trusted issuer (GitHub, Kubernetes) for an Entra token. Nothing to store.

Tick off each step and track your progress in the guide.

Open this task in Azure Portal, Hands On

Keep going