Skip to main content

policy_states

Creates, updates, deletes, gets or lists a policy_states resource.

Overview

Namepolicy_states
TypeResource
Idazure.policy_insights.policy_states

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
@odataobject
complianceStatestringCompliance state of the resource.
componentsarrayComponents state compliance records populated only when URL contains $expand=components clause.
effectiveParametersstringEffective parameters for the policy assignment.
isCompliantbooleanFlag which states whether the resource is compliant against the policy assignment it was evaluated against. This property is deprecated; please use ComplianceState instead.
managementGroupIdsstringComma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under.
policyAssignmentIdstringPolicy assignment ID.
policyAssignmentNamestringPolicy assignment name.
policyAssignmentOwnerstringPolicy assignment owner.
policyAssignmentParametersstringPolicy assignment parameters.
policyAssignmentScopestringPolicy assignment scope.
policyAssignmentVersionstringEvaluated policy assignment version.
policyDefinitionActionstringPolicy definition action, i.e. effect.
policyDefinitionCategorystringPolicy definition category.
policyDefinitionGroupNamesarrayPolicy definition group names.
policyDefinitionIdstringPolicy definition ID.
policyDefinitionNamestringPolicy definition name.
policyDefinitionReferenceIdstringReference ID for the policy definition inside the policy set, if the policy assignment is for a policy set.
policyDefinitionVersionstringEvaluated policy definition version.
policyEvaluationDetailsobjectPolicy evaluation details.
policySetDefinitionCategorystringPolicy set definition category, if the policy assignment is for a policy set.
policySetDefinitionIdstringPolicy set definition ID, if the policy assignment is for a policy set.
policySetDefinitionNamestringPolicy set definition name, if the policy assignment is for a policy set.
policySetDefinitionOwnerstringPolicy set definition owner, if the policy assignment is for a policy set.
policySetDefinitionParametersstringPolicy set definition parameters, if the policy assignment is for a policy set.
policySetDefinitionVersionstringEvaluated policy set definition version.
resourceGroupstringResource group name.
resourceIdstringResource ID.
resourceLocationstringResource location.
resourceTagsstringList of resource tags.
resourceTypestringResource type.
subscriptionIdstringSubscription ID.
timestampstring (date-time)Timestamp for the policy state record.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_query_results_for_resource_group_level_policy_assignmentselectsubscription_id, resource_group_name, policy_states_resource, policy_assignment_name$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the resource group level policy assignment.
list_query_results_for_resource_groupselectsubscription_id, resource_group_name, policy_states_resource$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the resources under the resource group.
list_query_results_for_policy_set_definitionselectsubscription_id, policy_states_resource, policy_set_definition_name$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the subscription level policy set definition.
list_query_results_for_policy_definitionselectsubscription_id, policy_states_resource, policy_definition_name$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the subscription level policy definition.
list_query_results_for_subscription_level_policy_assignmentselectsubscription_id, policy_states_resource, policy_assignment_name$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the subscription level policy assignment.
list_query_results_for_management_groupselectpolicy_states_resource, management_group_name$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the resources under the management group.
list_query_results_for_subscriptionselectsubscription_id, policy_states_resource$top, $orderby, $select, $from, $to, $filter, $apply, $skiptokenQueries policy states for the resources under the subscription.
list_query_results_for_resourceselectpolicy_states_resource, resource_id$top, $orderby, $select, $from, $to, $filter, $apply, $expand, $skiptokenQueries policy states for the resource.
summarize_for_management_groupexecpolicy_states_summary_resource, management_group_name$top, $from, $to, $filterSummarizes policy states for the resources under the management group.
summarize_for_subscriptionexecsubscription_id, policy_states_summary_resource$top, $from, $to, $filterSummarizes policy states for the resources under the subscription.
summarize_for_resource_groupexecsubscription_id, resource_group_name, policy_states_summary_resource$top, $from, $to, $filterSummarizes policy states for the resources under the resource group.
summarize_for_resourceexecpolicy_states_summary_resource, resource_id$top, $from, $to, $filterSummarizes policy states for the resource.
trigger_subscription_evaluationexecsubscription_idTriggers a policy evaluation scan for all the resources under the subscription.
trigger_resource_group_evaluationexecsubscription_id, resource_group_nameTriggers a policy evaluation scan for all the resources under the resource group.
summarize_for_policy_set_definitionexecsubscription_id, policy_states_summary_resource, policy_set_definition_name$top, $from, $to, $filterSummarizes policy states for the subscription level policy set definition.
summarize_for_policy_definitionexecsubscription_id, policy_states_summary_resource, policy_definition_name$top, $from, $to, $filterSummarizes policy states for the subscription level policy definition.
summarize_for_subscription_level_policy_assignmentexecsubscription_id, policy_states_summary_resource, policy_assignment_name$top, $from, $to, $filterSummarizes policy states for the subscription level policy assignment.
summarize_for_resource_group_level_policy_assignmentexecsubscription_id, resource_group_name, policy_states_summary_resource, policy_assignment_name$top, $from, $to, $filterSummarizes policy states for the resource group level policy assignment.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
management_group_namestringManagement group name. Required.
policy_assignment_namestringPolicy assignment name. Required.
policy_definition_namestringPolicy definition name. Required.
policy_set_definition_namestringPolicy set definition name. Required.
policy_states_resourcestringThe virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). Known values are: "default" and "latest". Required.
policy_states_summary_resourcestringThe virtual resource under PolicyStates resource type for summarize action. In a given time range, 'latest' represents the latest policy state(s) and is the only allowed value. "latest" Required.
resource_group_namestringResource group name. Required.
resource_idstringResource ID. Required.
subscription_idstringThe ID of the target subscription. The value must be an UUID. Required.
$applystringOData apply expression for aggregations. Default value is None.
$expandstringThe $expand query parameter. For example, to expand components use $expand=components. Default value is None.
$filterstringOData filter expression. Default value is None.
$fromstring (date-time)ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day). Default value is None.
$orderbystringOrdering expression using OData notation. One or more comma-separated column names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". Default value is None.
$selectstringSelect expression using OData notation. Limits the columns on each record to just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None.
$skiptokenstringSkiptoken is only provided if a previous response returned a partial result as a part of nextLink element. Default value is None.
$tostring (date-time)ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time. Default value is None.
$topintegerMaximum number of records to return. Default value is None.

SELECT examples

Queries policy states for the resource group level policy assignment.

SELECT
@odata,
complianceState,
components,
effectiveParameters,
isCompliant,
managementGroupIds,
policyAssignmentId,
policyAssignmentName,
policyAssignmentOwner,
policyAssignmentParameters,
policyAssignmentScope,
policyAssignmentVersion,
policyDefinitionAction,
policyDefinitionCategory,
policyDefinitionGroupNames,
policyDefinitionId,
policyDefinitionName,
policyDefinitionReferenceId,
policyDefinitionVersion,
policyEvaluationDetails,
policySetDefinitionCategory,
policySetDefinitionId,
policySetDefinitionName,
policySetDefinitionOwner,
policySetDefinitionParameters,
policySetDefinitionVersion,
resourceGroup,
resourceId,
resourceLocation,
resourceTags,
resourceType,
subscriptionId,
timestamp
FROM azure.policy_insights.policy_states
WHERE subscription_id = '{{ subscription_id }}' -- required
AND resource_group_name = '{{ resource_group_name }}' -- required
AND policy_states_resource = '{{ policy_states_resource }}' -- required
AND policy_assignment_name = '{{ policy_assignment_name }}' -- required
AND $top = '{{ $top }}'
AND $orderby = '{{ $orderby }}'
AND $select = '{{ $select }}'
AND $from = '{{ $from }}'
AND $to = '{{ $to }}'
AND $filter = '{{ $filter }}'
AND $apply = '{{ $apply }}'
AND $skiptoken = '{{ $skiptoken }}'
;

Lifecycle Methods

Summarizes policy states for the resources under the management group.

EXEC azure.policy_insights.policy_states.summarize_for_management_group 
@policy_states_summary_resource='{{ policy_states_summary_resource }}' --required,
@management_group_name='{{ management_group_name }}' --required,
@$top='{{ $top }}',
@$from='{{ $from }}',
@$to='{{ $to }}',
@$filter='{{ $filter }}'
;