Within the Microsoft Entra admin center, navigate to Identity, then Applications, and finally, App registrations. Proceed to the Deleted applications tab, where you can search for and select the specific app that needs restoration. Once chosen, click on "Restore app registration." It's important to note that this method works if the deletion occurred within the last 30 days. Should you attempt to recover an app deleted more than 30 days ago, it regrettably remains permanently unrecoverable.
For a more programmatic approach, PowerShell commands can be employed. The "Restore-AzureADMSDeletedAppRegistration" command, followed by the object ID of the app, allows for app restoration. To obtain the app object ID, utilize the "Get-AzureADApplication" PowerShell command with the app's ID. Here's how you can use these commands:
# Restore a deleted app using PowerShell
Restore-AzureADMSDeletedAppRegistration -ObjectId <app object ID>
To obtain the app object ID, you can use this command:
# Get the app object ID
Get-AzureADApplication -ObjectId <app ID>
Replace "<app ID>" with the appropriate app ID, and exercise caution when handling code. Once the app is restored, remember to reassign any necessary permissions or roles, as well as reconfigure the app's settings to its prior state.
An essential note to bear in mind is that the authority to restore deleted apps is reserved for administrators, as only they possess the requisite privileges to initiate the recovery process.