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.
Create a new targetDeviceGroup object for the remoteDesktopSecurityConfiguration object on the servicePrincipal. You can configure a maximum of 10 target device groups for the remoteDesktopSecurityConfiguraiton object on the servicePrincipal.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Application-RemoteDesktopConfig.ReadWrite.All |
Application.ReadWrite.All, Directory.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Application-RemoteDesktopConfig.ReadWrite.All |
Application.ReadWrite.All, Application.ReadWrite.OwnedBy, Directory.ReadWrite.All |
Important
In delegated scenarios with work or school accounts, the signed-in user must be an owner or member of the group or be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- Application Administrator
- Cloud Application Administrator
HTTP request
POST /servicePrincipals/{servicePrincipalsId}/remoteDesktopSecurityConfiguration/targetDeviceGroups
Request body
In the request body, supply a JSON representation of the targetDeviceGroup object.
You can specify the following properties when creating a targetDeviceGroup.
Property |
Type |
Description |
id |
String |
Object identifier of the group. Required. |
displayName |
String |
Display name of the group. Required. |
Response
If successful, this method returns a 201 Created
response code and a targetDeviceGroup object in the response body.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/servicePrincipals/00af5dfb-85da-4b41-a677-0c6b86dd34f8/remoteDesktopSecurityConfiguration/targetDeviceGroups
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.targetDeviceGroup",
"id": "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696",
"displayName": "Device Group A"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TargetDeviceGroup
{
OdataType = "#microsoft.graph.targetDeviceGroup",
Id = "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696",
DisplayName = "Device Group A",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].RemoteDesktopSecurityConfiguration.TargetDeviceGroups.PostAsync(requestBody);
mgc-beta service-principals remote-desktop-security-configuration target-device-groups create --service-principal-id {servicePrincipal-id} --body '{\
"@odata.type": "#microsoft.graph.targetDeviceGroup",\
"id": "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696",\
"displayName": "Device Group A"\
}\
'
// 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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewTargetDeviceGroup()
id := "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696"
requestBody.SetId(&id)
displayName := "Device Group A"
requestBody.SetDisplayName(&displayName)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
targetDeviceGroups, err := graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").RemoteDesktopSecurityConfiguration().TargetDeviceGroups().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TargetDeviceGroup targetDeviceGroup = new TargetDeviceGroup();
targetDeviceGroup.setOdataType("#microsoft.graph.targetDeviceGroup");
targetDeviceGroup.setId("b9e4eae4-b781-45a1-ce65-f2dd8ac3b696");
targetDeviceGroup.setDisplayName("Device Group A");
TargetDeviceGroup result = graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").remoteDesktopSecurityConfiguration().targetDeviceGroups().post(targetDeviceGroup);
const options = {
authProvider,
};
const client = Client.init(options);
const targetDeviceGroup = {
'@odata.type': '#microsoft.graph.targetDeviceGroup',
id: 'b9e4eae4-b781-45a1-ce65-f2dd8ac3b696',
displayName: 'Device Group A'
};
await client.api('/servicePrincipals/00af5dfb-85da-4b41-a677-0c6b86dd34f8/remoteDesktopSecurityConfiguration/targetDeviceGroups')
.version('beta')
.post(targetDeviceGroup);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\TargetDeviceGroup;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TargetDeviceGroup();
$requestBody->setOdataType('#microsoft.graph.targetDeviceGroup');
$requestBody->setId('b9e4eae4-b781-45a1-ce65-f2dd8ac3b696');
$requestBody->setDisplayName('Device Group A');
$result = $graphServiceClient->servicePrincipals()->byServicePrincipalId('servicePrincipal-id')->remoteDesktopSecurityConfiguration()->targetDeviceGroups()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Applications
$params = @{
"@odata.type" = "#microsoft.graph.targetDeviceGroup"
id = "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696"
displayName = "Device Group A"
}
New-MgBetaServicePrincipalRemoteDesktopSecurityConfigurationTargetDeviceGroup -ServicePrincipalId $servicePrincipalId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.target_device_group import TargetDeviceGroup
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TargetDeviceGroup(
odata_type = "#microsoft.graph.targetDeviceGroup",
id = "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696",
display_name = "Device Group A",
)
result = await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').remote_desktop_security_configuration.target_device_groups.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.targetDeviceGroup",
"id": "b9e4eae4-b781-45a1-ce65-f2dd8ac3b696",
"displayName": "Device Group A"
}