IPolicyAssignmentsOperations.CreateByIdWithHttpMessagesAsync(String, PolicyAssignment, Dictionary<String,List<String>>, CancellationToken) Method

Definition

Creates a policy assignment by ID.

public System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Azure.Management.ResourceManager.Models.PolicyAssignment>> CreateByIdWithHttpMessagesAsync (string policyAssignmentId, Microsoft.Azure.Management.ResourceManager.Models.PolicyAssignment parameters, System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = null);
abstract member CreateByIdWithHttpMessagesAsync : string * Microsoft.Azure.Management.ResourceManager.Models.PolicyAssignment * 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.Models.PolicyAssignment>>

Parameters

policyAssignmentId
System.String

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

parameters
PolicyAssignment

Parameters for policy assignment.

customHeaders
System.Collections.Generic.Dictionary<System.String,System.Collections.Generic.List<System.String>>

The headers that will be added to request.

cancellationToken
System.Threading.CancellationToken

The cancellation token.

Returns

System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<PolicyAssignment>>

Exceptions

Microsoft.Rest.Azure.CloudException

Thrown when the operation returned an invalid status code

Thrown when unable to deserialize the response

Thrown when a required parameter is null

Microsoft.Azure.Management.ResourceManager.Models.ErrorResponseException

Thrown when the operation returned an invalid status code

Remarks

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assigment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources.

Applies to