unable to delete service principal create by ai hub

Krzysztof Kawalec 0 Reputation points
2025-03-23T12:05:32.6433333+00:00

A timeout occurred while setting up Azure AI Hub. Some of the resources were set up, but not all.

There is still e.g. Service Principal which I can not remove because I have no access (message in the portal).

All options to add permissions are inactive.

From cli also no access.

How can I remove such service princical?

Commad:

az rest --method POST --uri https://graph.microsoft.com/beta/servicePrincipals/{TARGET SP OBJECT ID}/owners/$ref --body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{OWNER SP OBJECT ID}"}'

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,279 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Navya 17,820 Reputation points Microsoft External Staff
    2025-03-24T03:13:25.8133333+00:00

    Hi @Krzysztof Kawalec

    I understand you are unable to delete service principal from portal and CLI.

    Could you please confirm how the service principal was created? Try to delete the service principal using PowerShell

    Install-Module -Name Microsoft.Entra -Repository PSGallery -Scope CurrentUser -Force -AllowClobber
    
    Connect-Entra -Scopes 'Application.Read.All', 'Application.ReadWrite.OwnedBy'
    
    Get-EntraServicePrincipal // This lists all service principals. Copy your service principal's application ID.
    
    Get-EntraServicePrincipal -Filter "displayName eq '{replace your application name}'" | Remove-EntraServicePrincipal
    
    

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.