{servicePrincipalId} 指服务主体对象的 ID 。
id 称为Microsoft Entra 管理中心中的应用注册中的企业应用程序的对象 ID。
可以使用服务主体 ID 或 appId 来寻址服务主体。
id 和 appId 在 Microsoft Entra 管理中心 中的应用注册中分别称为“对象 ID”和“应用程序 (客户端) ID”。
POST /servicePrincipals/{servicePrincipalId}/synchronization/jobs/{jobId}/restart
POST /servicePrincipals(appId='{appId}')/synchronization/jobs/{jobId}/restart
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.ServicePrincipals.Item.Synchronization.Jobs.Item.Restart;
using Microsoft.Graph.Beta.Models;
var requestBody = new RestartPostRequestBody
{
Criteria = new SynchronizationJobRestartCriteria
{
ResetScope = SynchronizationJobRestartScope.Watermark | SynchronizationJobRestartScope.Escrows | SynchronizationJobRestartScope.QuarantineState,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.ServicePrincipals["{servicePrincipal-id}"].Synchronization.Jobs["{synchronizationJob-id}"].Restart.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Authorization", "Bearer <token>");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.serviceprincipals.item.synchronization.jobs.item.restart.RestartPostRequestBody restartPostRequestBody = new com.microsoft.graph.beta.serviceprincipals.item.synchronization.jobs.item.restart.RestartPostRequestBody();
SynchronizationJobRestartCriteria criteria = new SynchronizationJobRestartCriteria();
criteria.setResetScope(EnumSet.of(SynchronizationJobRestartScope.Watermark, SynchronizationJobRestartScope.Escrows, SynchronizationJobRestartScope.QuarantineState));
restartPostRequestBody.setCriteria(criteria);
graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").synchronization().jobs().bySynchronizationJobId("{synchronizationJob-id}").restart().post(restartPostRequestBody, requestConfiguration -> {
requestConfiguration.headers.add("Authorization", "Bearer <token>");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.service_principals.item.synchronization.jobs.item.restart.restart_request_builder import RestartRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.serviceprincipals.item.synchronization.jobs.item.restart.restart_post_request_body import RestartPostRequestBody
from msgraph_beta.generated.models.synchronization_job_restart_criteria import SynchronizationJobRestartCriteria
from msgraph_beta.generated.models.synchronization_job_restart_scope import SynchronizationJobRestartScope
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = RestartPostRequestBody(
criteria = SynchronizationJobRestartCriteria(
reset_scope = SynchronizationJobRestartScope.Watermark | SynchronizationJobRestartScope.Escrows | SynchronizationJobRestartScope.QuarantineState,
),
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Authorization", "Bearer <token>")
await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').synchronization.jobs.by_synchronization_job_id('synchronizationJob-id').restart.post(request_body, request_configuration = request_configuration)