How to renew an expiring app registration secret or certificate
Published
A client secret or certificate on an app registration cannot be extended. Renewing it means adding a second credential, moving everything that uses the old one across, and only then deleting the old one. Done in that order, nothing stops signing in.
Can you extend a secret that is about to expire?
No. The end date of a secret or certificate is fixed when it is created. What you can do is add a new credential next to the old one: an application can hold several secrets and certificates at once, each valid until its own end date. That overlap is what makes a renewal without downtime possible. Add the new credential, move the application to it, confirm it works, then remove the old one.
If you do not yet know which credentials are close to their end date, start with How to find expiring app registration secrets with PowerShell, then come back here with the list.
Is it an app registration or a service principal credential?
"Service principal credentials" can mean three things, and the renewal depends on which one you have:
- A client secret or certificate on an app registration. The common case: your own integration or script signs in as an application you registered. The credential lives under App registrations, Certificates & secrets, and this article covers it.
- A SAML signing certificate on an enterprise application. Entra signs the tokens it sends to a third-party application with it. It lives under Enterprise apps, Single sign-on, and has its own procedure, covered below.
- A credential added directly to a service principal. Graph can add secrets and certificates to a service principal itself. They do not show on the app registration’s Certificates & secrets page, only in the service principal’s
passwordCredentialsandkeyCredentials. The renewal follows the same pattern.
If the enterprise application belongs to a vendor’s multitenant app, its client secrets live in the vendor’s tenant, not yours. The vendor renews those.
What do you need before you start?
Three answers first:
- Who uses it. Ask the owners listed under the app registration’s Owners page. Then check the sign-in logs: in the Microsoft Entra admin center, go to Entra ID, Monitoring & health, Sign-in logs, open the Service principal sign-ins tab and filter on the application. The IP addresses show where the sign-ins come from, and where the log records it, the key ID of the credential used (
servicePrincipalCredentialKeyIdin Graph) shows which secret each caller uses. Reading the logs needs at least the Reports Reader role. - Where the secret is stored. Key Vault, pipeline variables, app settings, configuration files, a vendor’s admin portal. Every copy needs the new value.
- Who can make the change. An owner of the application can add and remove its credentials, whether a regular member or an Application Developer, and so can anyone with the Application Administrator or Cloud Application Administrator role.
How do you renew a client secret in the admin center?
- In the Microsoft Entra admin center, go to Entra ID, App registrations, and open the application.
- Select Certificates & secrets, Client secrets, New client secret.
- Give it a description that says when and why, such as "Renewed 2026-11 for payroll export".
- Pick an expiry. The admin center limits client secrets to 24 months, and Microsoft recommends less than 12.
- Select Add, then copy the Value column at once. It is never shown again after you leave the page.
The old secret stays in the list and keeps working until its end date. Leave it there for now.
How do you renew a client secret with PowerShell?
The script below does the same through Microsoft Graph PowerShell. Unlike the read-only scripts in the other articles on this site, this one writes: it adds a secret to the application, or with -RemoveKeyId removes one. Try it on a test app registration first.
It needs the delegated scope Application.ReadWrite.All and one of the roles above. An unattended job can use the application permission Application.ReadWrite.OwnedBy instead, which limits it to applications it owns.
# Written for the Microsoft Graph PowerShell SDK v2 (Microsoft.Graph.Applications).
# This script CHANGES the app registration: it adds a client secret, or removes one with -RemoveKeyId. Try it on a test app first.
param(
[Parameter(Mandatory)] [string] $AppId, # Application (client) ID of the app registration
[int] $Months = 6, # lifetime of the new secret
[string] $Description = "Renewed $(Get-Date -Format 'yyyy-MM-dd')",
[string] $RemoveKeyId # after the cutover: the KeyId of the old secret
)
Connect-MgGraph -Scopes "Application.ReadWrite.All" -NoWelcome
$app = Get-MgApplication -Filter "appId eq '$AppId'" -Property "id,appId,displayName,passwordCredentials"
if (-not $app) { throw "No app registration with client ID $AppId" }
# The secrets the application holds now, oldest end date first.
$app.PasswordCredentials | Sort-Object EndDateTime |
Format-Table DisplayName, KeyId, Hint, StartDateTime, EndDateTime -AutoSize
if ($RemoveKeyId) {
if (-not ($app.PasswordCredentials | Where-Object KeyId -eq $RemoveKeyId)) { throw "No secret with KeyId $RemoveKeyId" }
if (@($app.PasswordCredentials).Count -lt 2) { throw "That is the only secret. Add the new one first." }
Remove-MgApplicationPassword -ApplicationId $app.Id -KeyId $RemoveKeyId
"Removed secret $RemoveKeyId from $($app.DisplayName)."
return
}
# Add the new secret. Its value comes back in SecretText, this once only.
$new = Add-MgApplicationPassword -ApplicationId $app.Id -PasswordCredential @{
displayName = $Description
endDateTime = (Get-Date).ToUniversalTime().AddMonths($Months)
}
"New secret on $($app.DisplayName): KeyId $($new.KeyId), ends $($new.EndDateTime.ToString('yyyy-MM-dd'))"
$new.SecretText | Set-Clipboard # paste it straight into Key Vault or the pipeline variable, then clear the clipboard
Run it with -AppId to add the new secret, and note the old secret’s KeyId in the table it prints. After the cutover, run it again with -RemoveKeyId set to that KeyId. Without an end date Graph gives a new secret two years, so the script always sets one.
How do you renew a certificate credential?
A certificate follows the same pattern, with one difference: you bring the key pair.
- Get the new certificate. From your certificate authority, ideally issued into Key Vault. Microsoft advises against self-signed certificates in production.
- Upload the public part. In the app registration, select Certificates & secrets, Certificates, Upload certificate, and choose a
.cer,.pemor.crtfile. Never upload the private key. Note the Thumbprint it shows. - Switch the application to the new certificate: install it with its private key where the application runs and change the thumbprint or Key Vault reference in its configuration.
- Remove the old certificate once sign-ins with the new one succeed.
To do step 2 with Graph PowerShell, Update-MgApplication sets the application’s keyCredentials. Microsoft’s documentation is explicit that this replaces the whole collection: if you send only the new certificate, the existing ones are removed. Include every certificate you want to keep in the same call. The alternative, Add-MgApplicationKey, adds one certificate without touching the others, but it needs a proof-of-possession token signed with an existing valid certificate, so it cannot help an application whose only certificate has already expired.
In what order do you switch without downtime?
- Add the new credential. The old one keeps working.
- Deploy the new value or certificate to every place you found: Key Vault, pipelines, app settings, servers, vendor portals.
- Confirm in the service principal sign-ins that the application signs in successfully, and, where the key ID is recorded, that it uses the new credential.
- Wait a full business cycle, so that a monthly job or a sleeping server has had its chance to show up in the logs with the old credential.
- Remove the old credential.
What goes wrong, in the order it usually happens:
- The secret ID was copied, not the value. The Certificates & secrets page shows both columns. The Secret ID is the
KeyId, not something an application can sign in with. - A second consumer nobody knew about. A report on someone’s desktop, a test environment, a partner’s integration. The sign-in logs from step 3 are how you find it before the old secret goes.
- The old credential was removed first. A removed secret cannot be brought back, and the application fails the next time it asks for a token. Add first, always.
- An Azure DevOps service connection. If Azure DevOps created the service principal, Microsoft says to update the secret from the service connection in Azure DevOps, not in Entra.
What about SAML signing certificates?
They are renewed on the enterprise application, and the steps differ: under Single sign-on, SAML Certificates, you create a new certificate, save it, give its public part to the third-party application, then select Make certificate active. Entra mails the notification addresses 60, 30 and 7 days before the active certificate expires. Microsoft’s Manage federation certificates tutorial has the full procedure.
Can you avoid renewing at all?
Often, yes.
- Managed identities. Code running in Azure, such as Functions, App Service or virtual machines, can sign in with a managed identity. There is no secret to store or renew.
- Workload identity federation. GitHub Actions, Kubernetes and other external identity providers can exchange their own tokens for Entra tokens through a federated credential on the app registration. Again, no secret.
- Certificates over secrets where neither of those fits.
- App management policies set rules for the whole tenant: under Entra ID, Enterprise apps, Application policies, you can restrict the maximum lifetime of new secrets or block new secrets altogether. Microsoft notes that this needs a premium license.
What remains still needs to be renewed on time. How to get an alert before an Entra app secret expires sets up a warning mail for the ones you keep.
Checked against
- Microsoft.Graph.Applications 2.41.2 (
Get-MgApplicationwith-Filter,-Property,PasswordCredentials,KeyId,Hint,StartDateTime,EndDateTime;Add-MgApplicationPasswordwith-ApplicationIdand-PasswordCredential(displayName,endDateTime), returningSecretTextandKeyId;Remove-MgApplicationPasswordwith-ApplicationIdand-KeyId;Update-MgApplicationandAdd-MgApplicationKeyfor certificates) - Microsoft.Graph.Authentication 2.41.2 (
Connect-MgGraphwith-Scopes) - Module versions current on the PowerShell Gallery on 2026-11-11; the script parsed without errors by the Windows PowerShell 5.1 parser and uses no operators that only PowerShell 7 has
- Permissions, roles and behavior checked against Microsoft Learn on 2026-11-11: the Graph
addPassword,removePassword,addKeyand Update application pages; Add a certificate to an app or service principal using Microsoft Graph; Add and manage app credentials in Microsoft Entra ID; Tutorial: Manage federation certificates; Configure restrictions on how applications can be configured; Migrate applications away from secret-based authentication; Sign-in logs and Service principal sign-in logs - Microsoft Entra admin center paths, checked by name against Microsoft Learn: Entra ID, App registrations, Certificates & secrets, Client secrets, Certificates, Owners; Entra ID, Monitoring & health, Sign-in logs; Entra ID, Enterprise apps, Single sign-on, SAML Certificates; Entra ID, Enterprise apps, Application policies
- The script was not run against a tenant by us: run it against a test app registration first
Where does GlacierPoint Remind fit?
GlacierPoint Remind lists what expires in your tenant, app registration secrets and certificates and SAML signing certificates among them, with each item’s owner and the days left. On the Watch and MSP plans it runs daily and mails warnings 30, 14, 7 and 1 days before each end date. It reads names and dates, never a secret’s value, and it does not renew anything for you: the steps above stay yours. See how it works, or read the two earlier articles on this site: finding expiring secrets and alerting before they expire.