Skip to content

az ad sp delete should not delete role assignments #20805

Description

@jiasli

Describe the bug

az ad sp delete currently deletes role assignments for the specified service principal:

assignments = list_role_assignments(cmd, assignee=identifier, show_all=True)
if assignments:
logger.warning('Removing role assignments')
delete_role_assignments(cmd, [a['id'] for a in assignments])

But az ad app delete doesn't do this:

def delete_application(client, identifier):
object_id = _resolve_application(client, identifier)
client.delete(object_id)

Expected behavior

We should drop this behavior, so that we are in sync with

  1. Azure Portal
  2. Microsoft Graph REST API Delete servicePrincipal
  3. Azure PowerShell Remove-AzADServicePrincipal

The downside is that this leaves a role assignment whose assignee does not exist:

image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions