--- title: "Remove an Enterprise Application and its Service Principals from Entra ID" slug: "dex-wf-remove-enterprise-app-and-service-principals" updated: 2026-11-30T16:15:41Z published: 2026-11-30T16:15:41Z canonical: "documentation.sysaid.com/dex-wf-remove-enterprise-app-and-service-principals" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # Remove an Enterprise Application and its Service Principals from Entra ID Find all related app registrations and service principals by name, then cleanly delete them from your tenant. **Complexity:** Intermediate. **Impact:** security + access-control + app-lifecycle + cleanup. ## Why use this workflow When you decommission a SaaS vendor, revoke a third-party integration, or respond to a security incident involving a rogue OAuth app, you need to remove its footprint from Entra ID. A single vendor often leaves behind **multiple artifacts**: - One or more **app registrations** (the application object) in your tenant - One or more **enterprise applications** (service principals), including the home-tenant service principal *and* any consented multi-tenant service principals that point to the vendor's app - Variant naming (`SaaS Alerts`, `SaaS Alerts Respond`, `SAAS_ALERTS_RESPOND`) from different product lines or historical consents Deleting only the enterprise application that you see in the admin center can leave orphaned registrations or other related service principals behind, which can continue to hold permissions or reappear on the next sign-in. This workflow shows the complete find-and-remove flow. ## Expected outcomes ### After completing this workflow you will have: - A full inventory of every application and service principal matching the vendor's name prefix - All selected service principals deleted from Entra ID (which revokes their tokens and permissions) - All related app registrations deleted (which prevents re-instantiation) - Graph API audit entries for each deletion, suitable for compliance evidence ## Risks and considerations ### Before you delete - **Deletion is soft for 30 days.** App registrations and service principals move to the deleted items container and can be restored through `/directory/deletedItems`. After 30 days the deletion is permanent. - **Active dependencies break immediately.** If any workflow, Conditional Access policy, app role assignment, or automation authenticates as or to this app, it fails as soon as the service principal is deleted. - **Check for secrets and certificates** on the app registration before deletion. If the app holds keys that are used elsewhere, revoke them at the consuming system first. - **Filter carefully.** The Graph `$filter` operator does *not* support `contains()` on `displayName`. Use `startswith()`, or fetch the objects and filter client-side. A filter that is too broad (for example, `startswith(displayName,'S')`) can return many unrelated apps. - **Microsoft-owned first-party service principals** (for example, *Microsoft Graph* and *Office 365 SharePoint Online*) cannot be deleted and should not be, even if they match your filter. - **Delete order matters only loosely.** Deleting the app registration cascades to its home-tenant service principal, but multi-tenant service principals in your directory must be deleted separately. ## Required permissions | Permission | Why it's needed | | --- | --- | | Application.Read.All | List and search for applications and service principals to identify all items related to the vendor. | | Application.ReadWrite.All | Delete service principals and application registrations from the tenant. | | Directory.Read.All | Optional: read related directory objects (role assignments, owners) before deletion. | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` Find every Entra ID application and service principal whose name starts with '{AppNamePrefix}' (e.g. SaaS Alerts), show me the full list, and after I confirm, delete all selected service principals and their App Registrations from the tenant. ``` ## Manual steps (admin center) ### Step 1: Find every related enterprise application 1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as a **Cloud Application Administrator** or **Global Administrator**. 2. Go to **Identity** > **Applications** > **Enterprise applications** > **All applications**. 3. In the *Application type* filter, choose **All Applications**. Clear the default *Enterprise Applications* scope if you also need to see Microsoft-published and managed identity service principals. 4. In the search box, enter the vendor keyword (for example, `{AppName}`). Note every match, including variants with underscores, suffixes such as *Respond*, or different casing. ### Step 2: Find every related app registration 1. Go to **Identity** > **Applications** > **App registrations** > **All applications**. 2. Search for the same keyword and list the matches. These are the application objects that your tenant may own. ### Step 3: Review dependencies for each match 1. Open each enterprise application and check **Users and groups** (who is assigned), **Permissions** (which API scopes are consented), and the sign-in logs (whether it is still in use). 2. Open each app registration and check **Certificates & secrets** for active credentials. ### Step 4: Delete the enterprise applications (service principals) 1. In each enterprise application, go to **Manage** > **Properties**. 2. Select **Delete** at the top of the page and confirm. 3. Repeat for every related service principal. ### Step 5: Delete the app registrations 1. In each app registration, select **Delete** at the top of the **Overview** page and confirm. 2. Deleting an app registration that has a home-tenant service principal also deletes that service principal. ### Step 6: Verify 1. Return to **Enterprise applications** and **App registrations**, search the keyword again, and confirm that there are no results. 2. If you need to recover a deletion within the restore window, go to **App registrations** > **Deleted applications**. ## Microsoft Graph API ### 1. Search for matching app registrations Graph does not support `contains()` on `displayName`. Use `startswith()`: ``` GET https://graph.microsoft.com/v1.0/applications?$filter=startswith(displayName,'{AppNamePrefix}')&$select=id,displayName,appId ``` Example response: ``` {  "value": [    {      "id": "c3765acb-9d38-413a-988f-47d81d0b7102",      "displayName": "SAAS_ALERTS_RESPOND",      "appId": "7dcfe5f7-4054-4a4c-b55a-3195101a8059"    }  ] } ``` ### 2. Search for matching service principals ``` GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=startswith(displayName,'{AppNamePrefix}')&$select=id,displayName,appId,servicePrincipalType ``` Review each result. Ignore entries where `servicePrincipalType` is `ManagedIdentity` unless you intend to remove them. ### 3. (Optional) Inspect consented permissions before deletion ``` GET https://graph.microsoft.com/v1.0/servicePrincipals/{spId}/oauth2PermissionGrants GET https://graph.microsoft.com/v1.0/servicePrincipals/{spId}/appRoleAssignments ``` ### 4. Delete each service principal ``` DELETE https://graph.microsoft.com/v1.0/servicePrincipals/{spId} ``` A successful call returns `HTTP/1.1 204 No Content`. ### 5. Delete each app registration ``` DELETE https://graph.microsoft.com/v1.0/applications/{appObjectId} ``` Use the application's object ID (`id`), not the `appId` (client ID). A successful call returns `HTTP/1.1 204 No Content`. ### 6. Verify and (optionally) purge from the deleted items container List soft-deleted applications: ``` GET https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.application ``` Permanently delete an item (optional, bypasses the restore window): ``` DELETE https://graph.microsoft.com/v1.0/directory/deletedItems/{id} ``` ## PowerShell The Microsoft Graph PowerShell SDK provides `Get-MgApplication`, `Get-MgServicePrincipal`, `Remove-MgApplication`, and `Remove-MgServicePrincipal`. The workflow: 1. **Connect** with the `Application.ReadWrite.All` scope. 2. **Search** using `-Filter "startswith(displayName,'...')"`. Because `contains()` is not supported server-side, use `startswith`, or pull a broader set and filter with `Where-Object`. 3. **Preview** the matches and require `-Confirm` or `-WhatIf` before any destructive call. 4. **Delete service principals first**, then their app registrations. 5. **Verify** by re-running the search. To make this reusable, wrap the steps in a function with confirmation prompts, a `-WhatIf` preview mode, and a run-log summary. ``` # Quick preview (no deletions) Connect-MgGraph -Scopes "Application.ReadWrite.All" Get-MgServicePrincipal -Filter "startswith(displayName,'SaaS Alerts')" |    Select-Object Id, DisplayName, AppId ```