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:
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:
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:
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:
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:
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:
If that App registration is deleted permanently, you no longer can restore the service principal associated with it.
Reference: