Find Entra ID App Registrations With Secrets or Certificates Expiring Soon

Prev Next

Audit all app registrations for client secrets and certificates nearing expiration so you can coordinate renewals before outages occur.

Complexity: Intermediate. Impact: prevents-outage + security-hygiene + automation-friendly + scheduled-audit.

Why use this workflow

Every Entra ID application registration that integrates with APIs, SaaS apps, or custom workloads authenticates with either a client secret or a certificate (keyCredential). When those credentials expire, the app stops working. The result is broken integrations, failed automations, and production outages that are hard to diagnose after the fact.

This workflow gives you a repeatable audit so that you can find secrets and certificates that are about to expire across the entire tenant and coordinate renewals with the app owners in advance.

When to run it

  • Regularly, as a scheduled housekeeping task
  • Before scheduled change freezes or holidays
  • After you inherit a tenant or take over IT responsibilities
  • Whenever a production integration fails with an AADSTS7000222 error

Expected outcomes

  • A complete list of app registrations with credentials that expire within a window that you choose
  • For each app: display name, appId, object ID, credential type (secret or certificate), credential display name, and exact expiry timestamp
  • Enough information to contact app owners and coordinate renewal before expiration
  • An auditable record that you can re-run on a schedule or add to a runbook

Risks and considerations

  • Do not rotate credentials without the app owner. Replacing a secret or certificate on the app registration breaks any workload that still uses the old credential. Add the new one first, redeploy, then remove the old one.
  • Enterprise applications are not app registrations. This audit targets /applications (app registrations). Service principals for gallery SaaS apps rarely carry secrets that you manage. Focus on custom and line-of-business apps.
  • Federated credentials are not covered. Workload identity federation credentials (used by GitHub Actions, Kubernetes, and similar) do not expire the same way and use a different endpoint (/applications/{id}/federatedIdentityCredentials).
  • Permission scope. Reading passwordCredentials and keyCredentials requires Application.Read.All at minimum. The secret value is never returned after creation, only metadata.
  • Pagination matters. Large tenants can have many app registrations. Follow @odata.nextLink or you miss apps.

Required permissions

PermissionWhy it's needed
Application.Read.AllRequired to list app registrations and read their passwordCredentials and keyCredentials metadata
Directory.Read.AllUseful for resolving app owners when you coordinate renewals

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

Audit all Entra ID app registrations in our tenant and list any with client secrets or certificates expiring in the next {days} days. For each hit, include the app display name, appId, credential type, credential name, and exact expiry date, then identify the app owners so I can coordinate renewals.

Manual steps (admin center)

The admin center does not have a single tenant-wide expiry report, so this is a per-app inspection workflow. It suits small tenants and spot checks. For larger tenants, use the API or PowerShell approach.

  1. Sign in to the Microsoft Entra admin center as a Global Reader, Application Administrator, or higher.
  2. Go to Identity > Applications > App registrations.
  3. Select the All applications tab to include apps that you don't own.
  4. Use the column selector to show credential information, or open each app individually.
  5. For each app of interest, open it and go to Manage > Certificates & secrets.
  6. Review the Expires column on both the Client secrets and Certificates tabs.
  7. Note any credential that expires within your renewal window.
  8. Select Owners in the left navigation to identify who to contact for renewal coordination.

Microsoft Graph API

Use GET /applications and filter client-side on endDateTime. Graph does not support a server-side $filter on passwordCredentials/endDateTime, so retrieve the apps and evaluate the dates yourself.

Endpoint

GET https://graph.microsoft.com/v1.0/applications?$select=id,displayName,appId,passwordCredentials,keyCredentials&$top=999

Required header

Authorization: Bearer {access_token}

Sample response (trimmed)

{
  "value": [
    {
      "id": "a1b2c3d4-...",
      "appId": "9f8e7d6c-...",
      "displayName": "Contoso Payroll Integration",
      "passwordCredentials": [
        {
          "displayName": "prod-secret",
          "endDateTime": "2025-02-14T10:00:00Z",
          "keyId": "..."
        }
      ],
      "keyCredentials": []
    }
  ],
  "@odata.nextLink": "https://graph.microsoft.com/v1.0/applications?$skiptoken=..."
}

Client-side filter logic

  1. Parse each app's passwordCredentials[].endDateTime and keyCredentials[].endDateTime.
  2. Keep only credentials where endDateTime is between now and now + N days.
  3. Follow @odata.nextLink until it is absent. Do not stop at the first page.

Renewal workflow

To add a new secret before you remove the old one:

POST /v1.0/applications/{id}/addPassword
Content-Type: application/json

{
  "passwordCredential": {
    "displayName": "renewed-2025",
    "endDateTime": "2026-02-01T00:00:00Z"
  }
}

The response contains the secretText. This is the only time that the secret value is returned. Capture it securely and share it with the app owner through an approved channel.

PowerShell

The Microsoft.Graph PowerShell module handles pagination automatically with -All and is the easiest way to produce a reusable report.

Prerequisites

  • PowerShell 7 or later
  • The Microsoft.Graph module: Install-Module Microsoft.Graph -Scope CurrentUser
  • An account with Application.Read.All consent

Preview example

Connect-MgGraph -Scopes "Application.Read.All"
Get-MgApplication -All -Property Id,DisplayName,AppId,PasswordCredentials,KeyCredentials |
  Where-Object {
    ($_.PasswordCredentials.EndDateTime -lt (Get-Date).AddDays(7)) -or
    ($_.KeyCredentials.EndDateTime     -lt (Get-Date).AddDays(7))
  } |
  Select-Object DisplayName, AppId

Change the AddDays(7) value to the renewal window that you want to audit.