Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Delete a unifiedRoleDefinition object for an RBAC provider. You cannot delete built-in roles. This feature requires a Microsoft Entra ID P1 or P2 license.
The following RBAC providers are currently supported:
- Cloud PC
- device management (Intune)
- Defender (Microsoft Defender XDR Unified RBAC)
- directory (Microsoft Entra ID)
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
The following tables show the least privileged permission or permissions required to call this API on each supported resource type. Follow best practices to request least privileged permissions. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
For a Cloud PC provider
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
DeviceManagementRBAC.ReadWrite.All |
CloudPC.ReadWrite.All, Directory.ReadWrite.All, RoleManagement.ReadWrite.CloudPC, RoleManagement.ReadWrite.Directory |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
DeviceManagementRBAC.ReadWrite.All |
CloudPC.ReadWrite.All, Directory.ReadWrite.All, RoleManagement.ReadWrite.CloudPC, RoleManagement.ReadWrite.Directory |
For a device management (Intune) provider
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
RoleManagement.ReadWrite.Directory |
Directory.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
RoleManagement.ReadWrite.Directory |
Directory.ReadWrite.All |
For a Defender provider
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
DeviceManagementRBAC.ReadWrite.All |
CloudPC.ReadWrite.All, Directory.ReadWrite.All, RoleManagement.ReadWrite.CloudPC, RoleManagement.ReadWrite.Directory |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
DeviceManagementRBAC.ReadWrite.All |
CloudPC.ReadWrite.All, Directory.ReadWrite.All, RoleManagement.ReadWrite.CloudPC, RoleManagement.ReadWrite.Directory |
For a directory (Microsoft Entra ID) provider
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
RoleManagement.ReadWrite.Defender |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
RoleManagement.ReadWrite.Defender |
Not available. |
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. Privileged Role Administrator is the least privileged role supported for this operation.
HTTP request
To delete a role definition for a device management provider:
DELETE /roleManagement/deviceManagement/roleDefinitions/{id}
To delete a role definition for a directory provider:
DELETE /roleManagement/directory/roleDefinitions/{id}
To delete a role definition for a Cloud PC provider:
DELETE /roleManagement/cloudPc/roleDefinitions/{id}
To delete a role definition for a Defender provider:
DELETE /roleManagement/defender/roleDefinitions/{id}
Request body
Don't supply a request body for this method.
Response
If successful, this method returns 204 No Content
response code. It doesn't return anything in the response body.
Example 1: Delete a unifiedRoleDefinition resource for a directory provider
Request
DELETE https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions/f189965f-f560-4c59-9101-933d4c87a91a
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.RoleManagement.Directory.RoleDefinitions["{unifiedRoleDefinition-id}"].DeleteAsync();
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.RoleManagement().Directory().RoleDefinitions().ByUnifiedRoleDefinitionId("unifiedRoleDefinition-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.roleManagement().directory().roleDefinitions().byUnifiedRoleDefinitionId("{unifiedRoleDefinition-id}").delete();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/roleManagement/directory/roleDefinitions/f189965f-f560-4c59-9101-933d4c87a91a')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->roleManagement()->directory()->roleDefinitions()->byUnifiedRoleDefinitionId('unifiedRoleDefinition-id')->delete()->wait();
Import-Module Microsoft.Graph.Beta.Identity.Governance
Remove-MgBetaRoleManagementDirectoryRoleDefinition -UnifiedRoleDefinitionId $unifiedRoleDefinitionId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.role_management.directory.role_definitions.by_unified_role_definition_id('unifiedRoleDefinition-id').delete()
Response
The following example shows the response.
HTTP/1.1 204 No Content
Example 2: Delete a unifiedRoleDefinition resource for a Cloud PC provider
Request
DELETE https://graph.microsoft.com/beta/roleManagement/cloudPC/roleDefinitions/b7f5ddc1-b7dc-4d37-abce-b9d6fc15ffff
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.RoleManagement.CloudPC.RoleDefinitions["{unifiedRoleDefinition-id}"].DeleteAsync();
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.RoleManagement().CloudPC().RoleDefinitions().ByUnifiedRoleDefinitionId("unifiedRoleDefinition-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.roleManagement().cloudPC().roleDefinitions().byUnifiedRoleDefinitionId("{unifiedRoleDefinition-id}").delete();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/roleManagement/cloudPC/roleDefinitions/b7f5ddc1-b7dc-4d37-abce-b9d6fc15ffff')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->roleManagement()->cloudPC()->roleDefinitions()->byUnifiedRoleDefinitionId('unifiedRoleDefinition-id')->delete()->wait();
Import-Module Microsoft.Graph.Beta.DeviceManagement.Enrollment
Remove-MgBetaRoleManagementCloudPcRoleDefinition -UnifiedRoleDefinitionId $unifiedRoleDefinitionId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.role_management.cloud_p_c.role_definitions.by_unified_role_definition_id('unifiedRoleDefinition-id').delete()
Response
The following example shows the response.
HTTP/1.1 204 No Content
Example 3: Delete a unifiedRoleDefinition resource for a Defender provider
Request
DELETE https://graph.microsoft.com/beta/roleManagement/defender/roleDefinitions/f189965f-f560-4c59-9101-933d4c87a91a
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.RoleManagement.Defender.RoleDefinitions["{unifiedRoleDefinition-id}"].DeleteAsync();
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.RoleManagement().Defender().RoleDefinitions().ByUnifiedRoleDefinitionId("unifiedRoleDefinition-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.roleManagement().defender().roleDefinitions().byUnifiedRoleDefinitionId("{unifiedRoleDefinition-id}").delete();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/roleManagement/defender/roleDefinitions/f189965f-f560-4c59-9101-933d4c87a91a')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->roleManagement()->defender()->roleDefinitions()->byUnifiedRoleDefinitionId('unifiedRoleDefinition-id')->delete()->wait();
Import-Module Microsoft.Graph.Beta.DeviceManagement.Enrollment
Remove-MgBetaRoleManagementDefenderRoleDefinition -UnifiedRoleDefinitionId $unifiedRoleDefinitionId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.role_management.defender.role_definitions.by_unified_role_definition_id('unifiedRoleDefinition-id').delete()
Response
The following example shows the response.
HTTP/1.1 204 No Content