POST https://graph.microsoft.com/v1.0/deviceAppManagement/targetedManagedAppConfigurations/{targetedManagedAppConfigurationId}/assign
Content-type: application/json
Content-length: 338
{
"assignments": [
{
"@odata.type": "#microsoft.graph.targetedManagedAppPolicyAssignment",
"id": "8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b",
"target": {
"@odata.type": "microsoft.graph.configurationManagerCollectionAssignmentTarget",
"collectionId": "Collection Id value"
}
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.DeviceAppManagement.TargetedManagedAppConfigurations.Item.Assign;
using Microsoft.Graph.Models;
var requestBody = new AssignPostRequestBody
{
Assignments = new List<TargetedManagedAppPolicyAssignment>
{
new TargetedManagedAppPolicyAssignment
{
OdataType = "#microsoft.graph.targetedManagedAppPolicyAssignment",
Id = "8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b",
Target = new ConfigurationManagerCollectionAssignmentTarget
{
OdataType = "microsoft.graph.configurationManagerCollectionAssignmentTarget",
CollectionId = "Collection Id value",
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.DeviceAppManagement.TargetedManagedAppConfigurations["{targetedManagedAppConfiguration-id}"].Assign.PostAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc device-app-management targeted-managed-app-configurations assign post --targeted-managed-app-configuration-id {targetedManagedAppConfiguration-id} --body '{\
"assignments": [\
{\
"@odata.type": "#microsoft.graph.targetedManagedAppPolicyAssignment",\
"id": "8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b",\
"target": {\
"@odata.type": "microsoft.graph.configurationManagerCollectionAssignmentTarget",\
"collectionId": "Collection Id value"\
}\
}\
]\
}\
'
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphdeviceappmanagement "github.com/microsoftgraph/msgraph-sdk-go/deviceappmanagement"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphdeviceappmanagement.NewAssignPostRequestBody()
targetedManagedAppPolicyAssignment := graphmodels.NewTargetedManagedAppPolicyAssignment()
id := "8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b"
targetedManagedAppPolicyAssignment.SetId(&id)
target := graphmodels.NewConfigurationManagerCollectionAssignmentTarget()
collectionId := "Collection Id value"
target.SetCollectionId(&collectionId)
targetedManagedAppPolicyAssignment.SetTarget(target)
assignments := []graphmodels.TargetedManagedAppPolicyAssignmentable {
targetedManagedAppPolicyAssignment,
}
requestBody.SetAssignments(assignments)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.DeviceAppManagement().TargetedManagedAppConfigurations().ByTargetedManagedAppConfigurationId("targetedManagedAppConfiguration-id").Assign().Post(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.deviceappmanagement.targetedmanagedappconfigurations.item.assign.AssignPostRequestBody assignPostRequestBody = new com.microsoft.graph.deviceappmanagement.targetedmanagedappconfigurations.item.assign.AssignPostRequestBody();
LinkedList<TargetedManagedAppPolicyAssignment> assignments = new LinkedList<TargetedManagedAppPolicyAssignment>();
TargetedManagedAppPolicyAssignment targetedManagedAppPolicyAssignment = new TargetedManagedAppPolicyAssignment();
targetedManagedAppPolicyAssignment.setOdataType("#microsoft.graph.targetedManagedAppPolicyAssignment");
targetedManagedAppPolicyAssignment.setId("8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b");
ConfigurationManagerCollectionAssignmentTarget target = new ConfigurationManagerCollectionAssignmentTarget();
target.setOdataType("microsoft.graph.configurationManagerCollectionAssignmentTarget");
target.setCollectionId("Collection Id value");
targetedManagedAppPolicyAssignment.setTarget(target);
assignments.add(targetedManagedAppPolicyAssignment);
assignPostRequestBody.setAssignments(assignments);
graphClient.deviceAppManagement().targetedManagedAppConfigurations().byTargetedManagedAppConfigurationId("{targetedManagedAppConfiguration-id}").assign().post(assignPostRequestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const assign = {
assignments: [
{
'@odata.type': '#microsoft.graph.targetedManagedAppPolicyAssignment',
id: '8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b',
target: {
'@odata.type': 'microsoft.graph.configurationManagerCollectionAssignmentTarget',
collectionId: 'Collection Id value'
}
}
]
};
await client.api('/deviceAppManagement/targetedManagedAppConfigurations/{targetedManagedAppConfigurationId}/assign')
.post(assign);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\DeviceAppManagement\TargetedManagedAppConfigurations\Item\Assign\AssignPostRequestBody;
use Microsoft\Graph\Generated\Models\TargetedManagedAppPolicyAssignment;
use Microsoft\Graph\Generated\Models\ConfigurationManagerCollectionAssignmentTarget;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AssignPostRequestBody();
$assignmentsTargetedManagedAppPolicyAssignment1 = new TargetedManagedAppPolicyAssignment();
$assignmentsTargetedManagedAppPolicyAssignment1->setOdataType('#microsoft.graph.targetedManagedAppPolicyAssignment');
$assignmentsTargetedManagedAppPolicyAssignment1->setId('8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b');
$assignmentsTargetedManagedAppPolicyAssignment1Target = new ConfigurationManagerCollectionAssignmentTarget();
$assignmentsTargetedManagedAppPolicyAssignment1Target->setOdataType('microsoft.graph.configurationManagerCollectionAssignmentTarget');
$assignmentsTargetedManagedAppPolicyAssignment1Target->setCollectionId('Collection Id value');
$assignmentsTargetedManagedAppPolicyAssignment1->setTarget($assignmentsTargetedManagedAppPolicyAssignment1Target);
$assignmentsArray []= $assignmentsTargetedManagedAppPolicyAssignment1;
$requestBody->setAssignments($assignmentsArray);
$graphServiceClient->deviceAppManagement()->targetedManagedAppConfigurations()->byTargetedManagedAppConfigurationId('targetedManagedAppConfiguration-id')->assign()->post($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Devices.CorporateManagement
$params = @{
assignments = @(
@{
"@odata.type" = "#microsoft.graph.targetedManagedAppPolicyAssignment"
id = "8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b"
target = @{
"@odata.type" = "microsoft.graph.configurationManagerCollectionAssignmentTarget"
collectionId = "Collection Id value"
}
}
)
}
Set-MgDeviceAppManagementTargetedManagedAppConfiguration -TargetedManagedAppConfigurationId $targetedManagedAppConfigurationId -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.deviceappmanagement.targetedmanagedappconfigurations.item.assign.assign_post_request_body import AssignPostRequestBody
from msgraph.generated.models.targeted_managed_app_policy_assignment import TargetedManagedAppPolicyAssignment
from msgraph.generated.models.configuration_manager_collection_assignment_target import ConfigurationManagerCollectionAssignmentTarget
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AssignPostRequestBody(
assignments = [
TargetedManagedAppPolicyAssignment(
odata_type = "#microsoft.graph.targetedManagedAppPolicyAssignment",
id = "8b68c4a6-c4a6-8b68-a6c4-688ba6c4688b",
target = ConfigurationManagerCollectionAssignmentTarget(
odata_type = "microsoft.graph.configurationManagerCollectionAssignmentTarget",
collection_id = "Collection Id value",
),
),
],
)
await graph_client.device_app_management.targeted_managed_app_configurations.by_targeted_managed_app_configuration_id('targetedManagedAppConfiguration-id').assign.post(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。