Home > Net >  Can we restore the deleted applications in Azure Active Directory from Graph API?
Can we restore the deleted applications in Azure Active Directory from Graph API?

Time:09-03

I'm finding a way to restore my deleted application in Azure Active Directory from Graph API.

In the Portal, I can see my deleted applications here:

Deleted Applications

Using Powershell, I found this command to get that list:

Get-AzureADDeletedApplication 

In a similar way, is there any query to get those deleted applications listed from Graph API? Will it include deleted Enterprise Apps list too?

I'm unable to find the command for getting the list of deleted Enterprise Applications list from both PowerShell and Portal. Where can I see deleted Enterprise Apps in Azure Portal?

After getting the list, I want to restore one application. Is this possible? Can anyone help me out with the lost part?

CodePudding user response:

I tried to reproduce the same in my environment via Graph Explorer and got the below results:

I have deleted applications in my Azure Portal like below:

enter image description here

To get list of those deleted applications via Graph API, I ran the below query:

GET https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.application?$select=appid,deletedDateTime,displayName

Response:

enter image description here

To restore a specific deleted application like SriApp, I passed its object-id in the below query:

POST https://graph.microsoft.com/v1.0/directory/deletedItems/<app_objectId>/restore

Response:

enter image description here

Will it include deleted Enterprise Apps list too?

No, it won't include deleted Enterprise Apps list. You need to run separate query for it. Please note that, Enterprise Apps are a list of service principals.

Where can I see deleted Enterprise Apps in Azure Portal?

You cannot find deleted Enterprise Apps in Azure Portal. Alternatively, you can make use of PowerShell or Microsoft Graph.

To get the list of deleted service principals, you can run below Graph query:

GET https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.serviceprincipal?$select=appid,deletedDateTime,displayName

Response:

enter image description here

To restore a specific deleted service principal, you can run same query by replacing <object-id> with service principal object-id like below:

POST https://graph.microsoft.com/v1.0/directory/deletedItems/<service_principal_objectId>/restore

Make sure to restore App Registration first before restoring service principal. Otherwise, you will get error like below:

enter image description here

If that App registration is deleted permanently, you no longer can restore the service principal associated with it.

Reference:

Restore deleted enterprise application | Microsoft Docs

  • Related