Share via


PolicyAssignmentsOperationsExtensions.CreateByIdAsync Method

Definition

Creates or updates a policy assignment.

public static System.Threading.Tasks.Task<Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner> CreateByIdAsync (this Microsoft.Azure.Management.ResourceManager.Fluent.IPolicyAssignmentsOperations operations, string policyAssignmentId, Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner parameters, System.Threading.CancellationToken cancellationToken = default);
static member CreateByIdAsync : Microsoft.Azure.Management.ResourceManager.Fluent.IPolicyAssignmentsOperations * string * Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Management.ResourceManager.Fluent.Models.PolicyAssignmentInner>
<Extension()>
Public Function CreateByIdAsync (operations As IPolicyAssignmentsOperations, policyAssignmentId As String, parameters As PolicyAssignmentInner, Optional cancellationToken As CancellationToken = Nothing) As Task(Of PolicyAssignmentInner)

Parameters

operations
IPolicyAssignmentsOperations

The operations group for this extension method.

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.

cancellationToken
CancellationToken

The cancellation token.

Returns

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