Skip to main content
Five Steps for Cloud Compliance Readiness·A practical playbook for security teamsDownload
Guide · Microsoft 365

How to rotate app registration secrets in Microsoft 365

  • Updated 11 Nov 2026

This guide shows how to replace client secrets on Microsoft Entra app registrations before they expire, without breaking the app that uses them, and how to move to certificates where you can. It is for Entra and application admins who look after line-of-business apps, scripts and integrations.

Before you start

Before you start

A client secret is a password that an app registration uses to prove who it is. When it expires, the app stops signing in, so rotation is done with an overlap: add the new secret, switch the app over, then remove the old one.

  • Roles: Application Administrator, Cloud Application Administrator, or ownership of the specific app registration.
  • Tools: the Microsoft Entra admin center and the Microsoft Graph PowerShell SDK (Microsoft.Graph.Applications module).
  • Graph permissions: Application.Read.All for the read-only check, Application.ReadWrite.All for the changes (or Application.ReadWrite.OwnedBy when an app signs in as itself).
  • Know the consumer: for each app, find out where the secret is stored (a key vault, a pipeline variable, a config file) and who can update it.

Step by step

Step by step

  1. Read-only: list every secret and its expiry date. Run the command from the next section and note the apps whose secrets expire first. Write down the owner of each.
  2. Decide: secret or certificate. Microsoft recommends a trusted certificate over a client secret. If the app's code can use a certificate, upload one instead (Entra ID > App registrations > your app > Certificates & secrets > Certificates > Upload certificate). If the app runs on an Azure service that supports managed identities, a managed identity removes the secret entirely.
  3. Change: add the new secret. In the Entra admin center go to Entra ID > App registrations > your app > Certificates & secrets > Client secrets > New client secret. Enter a description that names the date and the owner, choose a lifetime, and select Add. Copy the secret value immediately: it is shown only once.
  4. Change: or add it with PowerShell. Replace the object ID with the app registration's Object ID (not the Application (client) ID):
    Connect-MgGraph -Scopes 'Application.ReadWrite.All'
    
    $appObjectId = '<app-object-id>'
    $newSecret = Add-MgApplicationPassword -ApplicationId $appObjectId -PasswordCredential @{
        displayName = 'rotated-' + (Get-Date -Format 'yyyy-MM-dd')
        endDateTime = (Get-Date).AddMonths(6)
    }
    $newSecret.KeyId   # note this; SecretText is returned only once
    Pick an end date that suits how often your team can realistically rotate.
  5. Change: store the new value where the app reads it (for example your key vault or pipeline secret store) and restart or redeploy the app. Never paste secrets into tickets or chat.
  6. Verify the app signs in with the new secret and that its jobs ran successfully. Check the app's own logs, then the Entra sign-in logs for the service principal.
  7. Change: remove the old secret. In the portal, open Certificates & secrets and delete the old row. With PowerShell, using the old secret's KeyId from the list:
    Remove-MgApplicationPassword -ApplicationId $appObjectId -KeyId '<old-key-id>'
    Double-check the key ID first: removing the wrong one breaks the app straight away.
  8. Record the next rotation date with the owner, ahead of the new expiry.

Check it worked

Check it worked

This command is read-only. It lists every client secret in the tenant with its expiry, soonest first:

Connect-MgGraph -Scopes 'Application.Read.All'

Get-MgApplication -All |
  ForEach-Object {
    $app = $_
    foreach ($cred in $app.PasswordCredentials) {
      [pscustomobject]@{
        App         = $app.DisplayName
        ObjectId    = $app.Id
        Secret      = $cred.DisplayName
        KeyId       = $cred.KeyId
        Expires     = $cred.EndDateTime
      }
    }
  } | Sort-Object Expires | Format-Table -AutoSize

For the app you rotated, expect to see only the new secret (its KeyId matches the one you noted) with the later expiry date, and the old row gone. Apps that no longer list any secret are using certificates, federated credentials or managed identities.

Common mistakes

Common mistakes

  • Deleting the old secret before the app uses the new one. Always overlap and verify first.
  • Not copying the value in time. Entra shows the secret value only once; if you miss it, add another secret.
  • Confusing the secret ID with the secret value, or the Application (client) ID with the Object ID used by the PowerShell cmdlets.
  • Picking the longest lifetime to avoid rotating. Long-lived secrets are what an attacker hopes to find; prefer a short lifetime you can keep up with, or a certificate.
  • Leaving secrets with no owner. Nobody renews them, and the app fails on the expiry date.
  • Storing secrets in scripts or shared notes. Keep them in a secret store with access limited to the app's owner.
  • Forgetting second consumers. The same secret is sometimes copied into more than one pipeline or server.

How ConfigCobra helps

How ConfigCobra helps

ConfigCobra reads your Microsoft 365 tenant through read-only Microsoft Graph permissions and never changes it, so the rotation itself stays with you.

  • The Microsoft 365 inventory lists app registrations and has built-in risk views for expired or soon-expiring app credentials and high-privilege app permissions, so you can see which apps to rotate first.
  • Scans run on a schedule (daily, weekly or monthly) or ad hoc, and drift detection alerts you by email when a control regresses.
  • For failing controls such as blocking password addition for applications, ConfigCobra provides copy-paste remediation steps and remediation impact analysis that lists the affected apps before you apply the fix.

See where your Microsoft 365 stands

A read-only assessment against the CIS benchmarks, prioritised so you know what to fix first.

Get in touch

Let's talk.

Whether you're evaluating ConfigCobra, running an audit, or managing a client fleet — we respond within one business day.

Free trial