Class PolicyAssignmentCollection
- Namespace
- Azure.ResourceManager.Resources
- Assembly
- Azure.ResourceManager.dll
A class representing a collection of PolicyAssignmentResource and their operations. Each PolicyAssignmentResource in the collection will belong to the same instance of ArmResource. To get a PolicyAssignmentCollection instance call the GetPolicyAssignments method from an instance of ArmResource.
public class PolicyAssignmentCollection : ArmCollection, IEnumerable<PolicyAssignmentResource>, IEnumerable, IAsyncEnumerable<PolicyAssignmentResource>
- Inheritance
-
PolicyAssignmentCollection
- Implements
-
IAsyncEnumerable<PolicyAssignmentResource>
- Inherited Members
Constructors
PolicyAssignmentCollection()
Initializes a new instance of the PolicyAssignmentCollection class for mocking.
protected PolicyAssignmentCollection()
Methods
CreateOrUpdate(WaitUntil, string, PolicyAssignmentData, CancellationToken)
This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Create
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual ArmOperation<PolicyAssignmentResource> CreateOrUpdate(WaitUntil waitUntil, string policyAssignmentName, PolicyAssignmentData data, CancellationToken cancellationToken = default)
Parameters
waitUntil
WaitUntilAzure.WaitUntil.Completed if the method should wait to return until the long-running operation has completed on the service; Azure.WaitUntil.Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
policyAssignmentName
stringThe name of the policy assignment.
data
PolicyAssignmentDataParameters for the policy assignment.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
ordata
is null.
CreateOrUpdateAsync(WaitUntil, string, PolicyAssignmentData, CancellationToken)
This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Create
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Task<ArmOperation<PolicyAssignmentResource>> CreateOrUpdateAsync(WaitUntil waitUntil, string policyAssignmentName, PolicyAssignmentData data, CancellationToken cancellationToken = default)
Parameters
waitUntil
WaitUntilAzure.WaitUntil.Completed if the method should wait to return until the long-running operation has completed on the service; Azure.WaitUntil.Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
policyAssignmentName
stringThe name of the policy assignment.
data
PolicyAssignmentDataParameters for the policy assignment.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
ordata
is null.
Exists(string, CancellationToken)
Checks to see if the resource exists in azure.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Get
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Response<bool> Exists(string policyAssignmentName, CancellationToken cancellationToken = default)
Parameters
policyAssignmentName
stringThe name of the policy assignment to get.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- Response<bool>
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
is null.
ExistsAsync(string, CancellationToken)
Checks to see if the resource exists in azure.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Get
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Task<Response<bool>> ExistsAsync(string policyAssignmentName, CancellationToken cancellationToken = default)
Parameters
policyAssignmentName
stringThe name of the policy assignment to get.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
is null.
Get(string, CancellationToken)
This operation retrieves a single policy assignment, given its name and the scope it was created at.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Get
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Response<PolicyAssignmentResource> Get(string policyAssignmentName, CancellationToken cancellationToken = default)
Parameters
policyAssignmentName
stringThe name of the policy assignment to get.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- Response<PolicyAssignmentResource>
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
is null.
GetAll(string, int?, CancellationToken)
This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group.
- Request Path/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_ListForResourceGroup
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
- Request Path/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_ListForResource
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
- Request Path/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_ListForManagementGroup
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
- Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_List
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Pageable<PolicyAssignmentResource> GetAll(string filter = null, int? top = null, CancellationToken cancellationToken = default)
Parameters
filter
stringThe filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}.
top
int?Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- Pageable<PolicyAssignmentResource>
A collection of PolicyAssignmentResource that may take multiple service requests to iterate over.
GetAllAsync(string, int?, CancellationToken)
This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group.
- Request Path/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_ListForResourceGroup
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
- Request Path/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_ListForResource
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
- Request Path/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_ListForManagementGroup
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
- Request Path/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments
- Operation IdPolicyAssignments_List
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual AsyncPageable<PolicyAssignmentResource> GetAllAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default)
Parameters
filter
stringThe filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}.
top
int?Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- AsyncPageable<PolicyAssignmentResource>
An async collection of PolicyAssignmentResource that may take multiple service requests to iterate over.
GetAsync(string, CancellationToken)
This operation retrieves a single policy assignment, given its name and the scope it was created at.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Get
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Task<Response<PolicyAssignmentResource>> GetAsync(string policyAssignmentName, CancellationToken cancellationToken = default)
Parameters
policyAssignmentName
stringThe name of the policy assignment to get.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- Task<Response<PolicyAssignmentResource>>
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
is null.
GetIfExists(string, CancellationToken)
Tries to get details for this resource from the service.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Get
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual NullableResponse<PolicyAssignmentResource> GetIfExists(string policyAssignmentName, CancellationToken cancellationToken = default)
Parameters
policyAssignmentName
stringThe name of the policy assignment to get.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- NullableResponse<PolicyAssignmentResource>
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
is null.
GetIfExistsAsync(string, CancellationToken)
Tries to get details for this resource from the service.
- Request Path/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}
- Operation IdPolicyAssignments_Get
- Default Api Version2022-06-01
- ResourcePolicyAssignmentResource
public virtual Task<NullableResponse<PolicyAssignmentResource>> GetIfExistsAsync(string policyAssignmentName, CancellationToken cancellationToken = default)
Parameters
policyAssignmentName
stringThe name of the policy assignment to get.
cancellationToken
CancellationTokenThe cancellation token to use.
Returns
- Task<NullableResponse<PolicyAssignmentResource>>
Exceptions
- ArgumentException
policyAssignmentName
is an empty string, and was expected to be non-empty.- ArgumentNullException
policyAssignmentName
is null.