共用方式為


IPolicyAssignmentsOperations.CreateByIdWithHttpMessagesAsync Method

Definition

Creates or updates a policy assignment.

public System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner>> CreateByIdWithHttpMessagesAsync (string policyAssignmentId, Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner parameters, System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>> customHeaders = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateByIdWithHttpMessagesAsync : string * Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner * System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner>>
Public Function CreateByIdWithHttpMessagesAsync (policyAssignmentId As String, parameters As PolicyAssignmentInner, Optional customHeaders As Dictionary(Of String, List(Of String)) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AzureOperationResponse(Of PolicyAssignmentInner))

Parameters

policyAssignmentId
String

The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.

parameters
PolicyAssignmentInner

Parameters for policy assignment.

customHeaders
Dictionary<String,List<String>>

The headers that will be added to request.

cancellationToken
CancellationToken

The cancellation token.

Returns

Exceptions

Thrown when the operation returned an invalid status code

Thrown when unable to deserialize the response

Thrown when a required parameter is null

Remarks

This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'.

Applies to