Skip to content

Commit 5c4d5df

Browse files
authored
Merge pull request #233607 from shanhix1/shannon/compliance-states
Compliance states documentation
2 parents 3cef393 + 6dbedb3 commit 5c4d5df

File tree

6 files changed

+170
-119
lines changed

6 files changed

+170
-119
lines changed

articles/governance/policy/assign-policy-bicep.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ If there are any existing resources that aren't compliant with this new assignme
104104
under **Non-compliant resources**.
105105

106106
For more information, see
107-
[How compliance works](./how-to/get-compliance-data.md#how-compliance-works).
107+
[How compliance works](./concepts/compliance-states.md).
108108

109109
## Clean up resources
110110

articles/governance/policy/assign-policy-template.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ ms.custom: subject-armqs, mode-arm, devx-track-arm-template
99

1010
The first step in understanding compliance in Azure is to identify the status of your resources.
1111
This quickstart steps you through the process of using an Azure Resource Manager template (ARM
12-
template) to create a policy assignment to identify virtual machines that aren't using managed
13-
disks. At the end of this process, you'll successfully identify virtual machines that aren't using
14-
managed disks. They're _non-compliant_ with the policy assignment.
12+
template) to create a policy assignment that identifies virtual machines that aren't using managed
13+
disks, and flags them as _non-compliant_ to the policy assignment.
1514

1615
[!INCLUDE [About Azure Resource Manager](../../../includes/resource-manager-quickstart-introduction.md)]
1716

@@ -58,7 +57,7 @@ The resource defined in the template is:
5857
| Resource group | Select **Create new**, specify a name, and then select **OK**. In the screenshot, the resource group name is _mypolicyquickstart\<Date in MMDD\>rg_. |
5958
| Location | Select a region. For example, **Central US**. |
6059
| Policy Assignment Name | Specify a policy assignment name. You can use the policy definition display if you want. For example, _Audit VMs that do not use managed disks_. |
61-
| Rg Name | Specify a resource group name where you want to assign the policy to. In this quickstart, use the default value **[resourceGroup().name]**. **[resourceGroup()](../../azure-resource-manager/templates/template-functions-resource.md#resourcegroup)** is a template function that retrieves the resource group. |
60+
| Resource Group Name | Specify a resource group name where you want to assign the policy to. In this quickstart, use the default value **[resourceGroup().name]**. **[resourceGroup()](../../azure-resource-manager/templates/template-functions-resource.md#resourcegroup)** is a template function that retrieves the resource group. |
6261
| Policy Definition ID | Specify **/providers/Microsoft.Authorization/policyDefinitions/0a914e76-4921-4c19-b460-a2d36003525a**. |
6362
| I agree to the terms and conditions stated above | (Select) |
6463

@@ -86,7 +85,7 @@ If there are any existing resources that aren't compliant with this new assignme
8685
under **Non-compliant resources**.
8786

8887
For more information, see
89-
[How compliance works](./how-to/get-compliance-data.md#how-compliance-works).
88+
[How compliance works](./concepts/compliance-states.md).
9089

9190
## Clean up resources
9291

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Azure Policy compliance states
3+
description: This article describes the concept of compliance states in Azure Policy.
4+
ms.date: 04/05/2023
5+
ms.topic: conceptual
6+
---
7+
8+
# Azure Policy compliance states
9+
10+
## How compliance works
11+
12+
When initiative or policy definitions are assigned, Azure Policy determines which resources are [applicable](./policy-applicability.md) then evaluates those which haven't been [excluded](./assignment-structure.md#excluded-scopes) or [exempted](./exemption-structure.md). Evaluation yields **compliance states** based on conditions in the policy rule and each resources' adherence to those requirements.
13+
14+
## Available compliance states
15+
16+
### Non-compliant
17+
18+
Policy assignments with `audit`, `auditIfNotExists`, or `modify` effects are considered non-compliant for _new_, _updated_, or _existing_ resources when the conditions of the policy rule evaluate to **TRUE**.
19+
20+
Policy assignments with `append`, `deny`, and `deployIfNotExists` effects are considered non-compliant for _existing_ resources when the conditions of the policy rule evaluate to **TRUE**. _New_ and _updated_ resources are automatically remediated or denied at request time to enforce compliance. When a previously existing non-compliant resource is updated, the compliance state remains non-compliant until the resource deployment and Policy evaluation complete.
21+
22+
> [!NOTE]
23+
> The DeployIfNotExist and AuditIfNotExist effects require the IF statement to be TRUE and the
24+
> existence condition to be FALSE to be non-compliant. When TRUE, the IF condition triggers
25+
> evaluation of the existence condition for the related resources.
26+
27+
Policy assignments with `manual` effects are considered non-compliant under two circumstances:
28+
1. The policy definition has a default compliance state of non-compliant and there is no active [attestation](./attestation-structure.md) for the applicable resource stating otherwise.
29+
1. The resource has been attested as non-compliant.
30+
31+
To determine
32+
the reason a resource is non-compliant or to find the change responsible, see
33+
[Determine non-compliance](../how-to/determine-non-compliance.md). To [remediate](./remediation-structure.md) non-compliant resources for `deployIfNotExists` and `modify` policies, see [Remediate non-compliant resources with Azure Policy](../how-to/remediate-resources.md).
34+
35+
### Compliant
36+
37+
Policy assignments with `append`, `audit`, `auditIfNotExists`, `deny`, `deployIfNotExists`, or `modify` effects are considered compliant for _new_, _updated_, or _existing_ resources when the conditions of the policy rule evaluate to **FALSE**.
38+
39+
Policy assignments with `manual` effects are considered compliant under two circumstances:
40+
1. The policy definition has a default compliance state of compliant and there is no active [attestation](./attestation-structure.md) for the applicable resource stating otherwise.
41+
1. The resource has been attested as compliant.
42+
43+
### Error
44+
45+
The error compliance state is given to policy assignments that generate a system error, such as template or evaluation error.
46+
47+
### Conflicting
48+
49+
A policy assignment is considered conflicting when there are two or more policy assignments existing in the same scope with contradicting or conflicting rules. For example, two definitions that append the same tag with different values.
50+
51+
### Exempt
52+
53+
An applicable resource has a compliance state of exempt for a policy assignment when it is in the scope of an [exemption](./exemption-structure.md).
54+
55+
> [!NOTE]
56+
> _Exempt_ is different than _excluded_. For more details, see [scope](./scope.md).
57+
58+
### Unknown (preview)
59+
60+
Unknown is the default compliance state for definitions with `manual` effect, unless the default has been explicitly set to compliant or non-compliant. This state indicates that an [attestation](./attestation-structure.md) of compliance is warranted. This compliance state only occurs for policy assignments with `manual` effect.
61+
62+
### Not registered
63+
64+
This compliance state is visible in portal when the Azure Policy Resource Provider hasn't been registered, or when the account logged in doesn't have permission to read compliance data.
65+
66+
> [!NOTE]
67+
> If compliance state is being reported as **Not registered**, verify that the
68+
> **Microsoft.PolicyInsights** Resource Provider is registered and that the user has the appropriate Azure role-based access control (Azure RBAC) permissions as described in
69+
> [Azure RBAC permissions in Azure Policy](../overview.md#azure-rbac-permissions-in-azure-policy).
70+
> To register Microsoft.PolicyInsights, [follow these steps](../../../azure-resource-manager/management/resource-providers-and-types.md).
71+
72+
### Not started
73+
74+
This compliance state indicates that the evaluation cycle hasn't started for the policy or resource.
75+
76+
## Example
77+
78+
Now that you have an understanding of what compliance states exist and what each one means, let's look at an example using compliant and non-compliant states.
79+
80+
Suppose you have a resource group - ContosoRG, with some storage accounts
81+
(highlighted in red) that are exposed to public networks.
82+
83+
:::image type="complex" source="../media/getting-compliance-data/resource-group01.png" alt-text="Diagram of storage accounts exposed to public networks in the Contoso R G resource group." border="false":::
84+
Diagram showing images for five storage accounts in the Contoso R G resource group. Storage accounts one and three are blue, while storage accounts two, four, and five are red.
85+
:::image-end:::
86+
87+
In this example, you need to be wary of security risks. Assume you assign a policy definition that audits for storage accounts that are exposed to public networks, and that no exemptions are created for this assignment. The policy checks for applicable resources (which includes all storage accounts in the ContosoRG resource group), then evaluates those resources that aren't excluded from evaluation. It audits the three storage accounts exposed to public networks, changing their compliance states to **Non-compliant.** The remainder are marked **compliant**.
88+
89+
:::image type="complex" source="../media/getting-compliance-data/resource-group03.png" alt-text="Diagram of storage account compliance in the Contoso R G resource group." border="false":::
90+
Diagram showing images for five storage accounts in the Contoso R G resource group. Storage accounts one and three now have green checkmarks beneath them, while storage accounts two, four, and five now have red warning signs beneath them.
91+
:::image-end:::
92+
93+
## Compliance rollup
94+
95+
Compliance state is determined per-resource, per-policy assignment. However, we often need a big-picture view of the state of the environment, which is where aggregate compliance comes into play.
96+
97+
There are several ways to view aggregated compliance results in the portal:
98+
99+
| Aggregate compliance view | Factors determining compliance state |
100+
| --- | --- |
101+
| Scope | All policies within the selected scope |
102+
| Initiative | All policies within the initiative |
103+
| Initiative group or control | All policies within the group or control |
104+
| Policy | All applicable resources |
105+
| Resource | All applicable policies |
106+
107+
### Comparing different compliance states
108+
109+
So how is the aggregate compliance state determined if multiple resources or policies have different compliance states themselves? Azure Policy ranks each compliance state so that one "wins" over another in this situation. The rank order is:
110+
1. Non-compliant
111+
1. Compliant
112+
1. Error
113+
1. Conflicting
114+
1. Exempted
115+
1. Unknown (preview)
116+
117+
> [!NOTE]
118+
> [Not started](#not-started) and [not registered](#not-registered) aren't considered in compliance rollup calculations.
119+
120+
With this ranking, if there are both non-compliant and compliant states, then the rolled up aggregate would be non-compliant, and so on. Let's look at an example:
121+
122+
Assume an initiative contains 10 policies, and a resource is exempt from one policy but compliant to the remaining nine. Because a compliant state has a higher rank than an exempted state, the resource would register as compliant in the rolled-up summary of the initiative. So, a resource only shows as exempt for the entire initiative if it's exempt from, or has unknown compliance to, every other single applicable policy in that initiative. On the other extreme, a resource that is non-compliant to at least one applicable policy in the initiative has an overall compliance state of non-compliant, regardless of the remaining applicable policies.
123+
124+
### Compliance percentage
125+
126+
The compliance percentage is determined by dividing **Compliant**, **Exempt**, and **Unknown** resources by _total resources_. _Total resources_ include **Compliant**, **Non-compliant**,
127+
**Exempt**, and **Conflicting** resources. The overall compliance numbers are the sum of distinct
128+
resources that are **Compliant**, **Exempt**, and **Unknown** divided by the sum of all distinct resources.
129+
130+
```text
131+
overall compliance % = (compliant + exempt + unknown) / (compliant + non-compliant + exempt + conflicting)
132+
```
133+
134+
In the image shown, there are 20 distinct resources that are applicable and only one is **Non-compliant**.
135+
The overall resource compliance is 95% (19 out of 20).
136+
137+
:::image type="content" source="../media/getting-compliance-data/simple-compliance.png" alt-text="Screenshot of policy compliance details from Compliance page." border="false":::
138+
139+
## Next steps
140+
141+
- Learn how to [get compliance data](../how-to/get-compliance-data.md)
142+
- Learn how to [determine causes of non-compliance](../how-to/determine-non-compliance.md)
143+
- Get compliance data through [ARG query samples](../samples/resource-graph-samples.md)

articles/governance/policy/concepts/scope.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ The following table is a comparison of the scope options:
7979
|**Resource Manager object** | - | - | &#10004; |
8080
|**Requires modifying policy assignment object** | &#10004; | &#10004; | - |
8181

82+
So how do you choose whether to use an exclusion or exemption? Typically exclusions are recommended to permanently bypass evaluation for a broad scope like a test environment which doesn't require the same level of governance. Exemptions are recommended for time-bound or more specific scenarios where a resource or resource hierarchy should still be tracked and would otherwise be evaluated, but there is a specific reason it should not be assessed for compliance.
83+
8284
## Next steps
8385

8486
- Learn about the [policy definition structure](./definition-structure.md).

0 commit comments

Comments
 (0)