Skip to content

Commit 04c1a28

Browse files
committed
Removed deprecated effects, added RP mode applicability logic, added compliance weights, added info about effect interchangeability
1 parent 05b2185 commit 04c1a28

File tree

4 files changed

+82
-160
lines changed

4 files changed

+82
-160
lines changed

articles/governance/policy/concepts/definition-structure.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ see [Tag support for Azure resources](../../../azure-resource-manager/management
136136

137137
The following Resource Provider modes are fully supported:
138138

139-
- `Microsoft.Kubernetes.Data` for managing your Kubernetes clusters on or off Azure. Definitions
140-
using this Resource Provider mode use effects _audit_, _deny_, and _disabled_. Use
141-
of the [EnforceOPAConstraint](./effects.md#enforceopaconstraint) effect is _deprecated_.
139+
- `Microsoft.Kubernetes.Data` for managing your Kubernetes clusters on or off Azure, and for Azure Policy components that target [Azure Arc-enabled Kubernetes clusters](../../../aks/intro-kubernetes.md) components such as pods, containers, and ingresses. Definitions
140+
using this Resource Provider mode use effects _audit_, _deny_, and _disabled_.
142141
- `Microsoft.KeyVault.Data` for managing vaults and certificates in
143142
[Azure Key Vault](../../../key-vault/general/overview.md). For more information on these policy
144143
definitions, see

articles/governance/policy/concepts/effects.md

Lines changed: 7 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ These effects are currently supported in a policy definition:
2323
- [Manual (preview)](#manual-preview)
2424
- [Modify](#modify)
2525

26-
The following effects are _deprecated_:
26+
## Interchanging effects
2727

28-
- [EnforceOPAConstraint](#enforceopaconstraint)
29-
- [EnforceRegoPolicy](#enforceregopolicy)
28+
Sometimes multiple effects can be valid for a given policy definition. Parameters are often used to specify allowed effect values so that a single definition can be more versatile. However, it is important to note that not all effects are interchangeable. Resource properties and logic in the policy rule can determine whether a cerain effect is considered valid to the policy definition. For example, policy definitions with effect **AuditIfNotExists** require additional details in the policy rule which are not required for policies with effect **Audit**. The effects also behave differently. **Audit** policies will assess a resource's compliance based on its own properties, while **AuditIfNotExists** policies will assess a resource's compliance based on a child or extension resource's properties.
3029

31-
> [!IMPORTANT]
32-
> In place of the **EnforceOPAConstraint** or **EnforceRegoPolicy** effects, use _audit_ and
33-
> _deny_ with Resource Provider mode `Microsoft.Kubernetes.Data`. The built-in policy definitions
34-
> have been updated. When existing policy assignments of these built-in policy definitions are
35-
> modified, the _effect_ parameter must be changed to a value in the updated _allowedValues_ list.
30+
The following is general guidance around interchangeable effects:
31+
- **Audit**, **Deny**, and either **Modify** or **Append** are often interchangeable.
32+
- **AuditIfNotExists** and **DeployIfNotExists** are often interchangeable.
33+
- **Manual** is not interchangeable.
34+
- **Disabled** is interchangeable with any effect.
3635

3736
## Order of evaluation
3837

@@ -621,133 +620,6 @@ When **enforcementMode** is **Disabled**_**, resources are still evaluated. Logg
621620
logs, and the policy effect don't occur. For more information, see
622621
[policy assignment - enforcement mode](./assignment-structure.md#enforcement-mode).
623622

624-
## EnforceOPAConstraint
625-
626-
This effect is used with a policy definition _mode_ of `Microsoft.Kubernetes.Data`. It's used to
627-
pass Gatekeeper v3 admission control rules defined with
628-
[OPA Constraint Framework](https://github.com/open-policy-agent/frameworks/tree/master/constraint#opa-constraint-framework)
629-
to [Open Policy Agent](https://www.openpolicyagent.org/) (OPA) to Kubernetes clusters on Azure.
630-
631-
> [!IMPORTANT]
632-
> The limited preview policy definitions with **EnforceOPAConstraint** effect and the related
633-
> **Kubernetes Service** category are _deprecated_. Instead, use the effects _audit_ and _deny_ with
634-
> Resource Provider mode `Microsoft.Kubernetes.Data`.
635-
636-
### EnforceOPAConstraint evaluation
637-
638-
The Open Policy Agent admission controller evaluates any new request on the cluster in real time.
639-
Every 15 minutes, a full scan of the cluster is completed and the results reported to Azure Policy.
640-
641-
### EnforceOPAConstraint properties
642-
643-
The **details** property of the EnforceOPAConstraint effect has the subproperties that describe the
644-
Gatekeeper v3 admission control rule.
645-
646-
- **constraintTemplate** (required)
647-
- The Constraint template CustomResourceDefinition (CRD) that defines new Constraints. The
648-
template defines the Rego logic, the Constraint schema, and the Constraint parameters that are
649-
passed via **values** from Azure Policy.
650-
- **constraint** (required)
651-
- The CRD implementation of the Constraint template. Uses parameters passed via **values** as
652-
`{{ .Values.<valuename> }}`. In the following example, these values are `{{ .Values.cpuLimit }}`
653-
and `{{ .Values.memoryLimit }}`.
654-
- **values** (optional)
655-
- Defines any parameters and values to pass to the Constraint. Each value must exist in the
656-
Constraint template CRD.
657-
658-
### EnforceOPAConstraint example
659-
660-
Example: Gatekeeper v3 admission control rule to set container CPU and memory resource limits in
661-
Kubernetes.
662-
663-
```json
664-
"if": {
665-
"allOf": [
666-
{
667-
"field": "type",
668-
"in": [
669-
"Microsoft.ContainerService/managedClusters",
670-
"AKS Engine"
671-
]
672-
},
673-
{
674-
"field": "location",
675-
"equals": "westus2"
676-
}
677-
]
678-
},
679-
"then": {
680-
"effect": "enforceOPAConstraint",
681-
"details": {
682-
"constraintTemplate": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/container-resource-limits/template.yaml",
683-
"constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/container-resource-limits/constraint.yaml",
684-
"values": {
685-
"cpuLimit": "[parameters('cpuLimit')]",
686-
"memoryLimit": "[parameters('memoryLimit')]"
687-
}
688-
}
689-
}
690-
```
691-
692-
## EnforceRegoPolicy
693-
694-
This effect is used with a policy definition _mode_ of `Microsoft.ContainerService.Data`. It's used
695-
to pass Gatekeeper v2 admission control rules defined with
696-
[Rego](https://www.openpolicyagent.org/docs/latest/policy-language/#what-is-rego) to
697-
[Open Policy Agent](https://www.openpolicyagent.org/) (OPA) on
698-
[Azure Kubernetes Service](../../../aks/intro-kubernetes.md).
699-
700-
> [!IMPORTANT]
701-
> The limited preview policy definitions with **EnforceRegoPolicy** effect and the related
702-
> **Kubernetes Service** category are _deprecated_. Instead, use the effects _audit_ and _deny_ with
703-
> Resource Provider mode `Microsoft.Kubernetes.Data`.
704-
705-
### EnforceRegoPolicy evaluation
706-
707-
The Open Policy Agent admission controller evaluates any new request on the cluster in real time.
708-
Every 15 minutes, a full scan of the cluster is completed and the results reported to Azure Policy.
709-
710-
### EnforceRegoPolicy properties
711-
712-
The **details** property of the EnforceRegoPolicy effect has the subproperties that describe the
713-
Gatekeeper v2 admission control rule.
714-
715-
- **policyId** (required)
716-
- A unique name passed as a parameter to the Rego admission control rule.
717-
- **policy** (required)
718-
- Specifies the URI of the Rego admission control rule.
719-
- **policyParameters** (optional)
720-
- Defines any parameters and values to pass to the rego policy.
721-
722-
### EnforceRegoPolicy example
723-
724-
Example: Gatekeeper v2 admission control rule to allow only the specified container images in AKS.
725-
726-
```json
727-
"if": {
728-
"allOf": [
729-
{
730-
"field": "type",
731-
"equals": "Microsoft.ContainerService/managedClusters"
732-
},
733-
{
734-
"field": "location",
735-
"equals": "westus2"
736-
}
737-
]
738-
},
739-
"then": {
740-
"effect": "EnforceRegoPolicy",
741-
"details": {
742-
"policyId": "ContainerAllowedImages",
743-
"policy": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/KubernetesService/container-allowed-images/limited-preview/gatekeeperpolicy.rego",
744-
"policyParameters": {
745-
"allowedContainerImagesRegex": "[parameters('allowedContainerImagesRegex')]"
746-
}
747-
}
748-
}
749-
```
750-
751623
## Manual (preview)
752624

753625
The new `manual` (preview) effect enables you to self-attest the compliance of resources or scopes. Unlike other policy definitions that actively scan for evaluation, the Manual effect allows for manual changes to the compliance state. To change the compliance of a resource or scope targeted by a manual policy, you'll need to create an [attestation](attestation-structure.md). The [best practice](attestation-structure.md#best-practices) is to design manual policies that target the scope which defines the boundary of resources whose compliance need attesting.

articles/governance/policy/concepts/policy-applicability.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Condition(s) in the `if` block of the policy rule are evaluated for applicabilit
2121
> [!NOTE]
2222
> Applicability is different from compliance, and the logic used to determine each is different. If a resource is **applicable** that means it is relevant to the policy. If a resource is **compliant** that means it adheres to the policy. Sometimes only certain conditions from the policy rule impact applicability, while all conditions of the policy rule impact compliance state.
2323
24-
## Applicability logic for Append/Modify/Audit/Deny/RP Mode specific effects
24+
## Applicability logic for resource manager modes
25+
26+
### Append, Audit, Manual, Modify and Deny policy effects
2527

2628
Azure Policy evaluates only `type`, `name`, and `kind` conditions in the policy rule `if` expression and treats other conditions as true (or false when negated). If the final evaluation result is true, the policy is applicable. Otherwise, it's not applicable.
2729

@@ -35,9 +37,27 @@ Following are special cases to the previously described applicability logic:
3537
|When the `if` conditions consist of only `type` and `kind` or `type` and `name` conditions |Only type conditions are considered when deciding applicability |
3638
|When any conditions (including deployment parameters) include a `location` condition |Will not be applicable to subscriptions |
3739

38-
## Applicability logic for AuditIfNotExists and DeployIfNotExists policy effects
40+
### AuditIfNotExists and DeployIfNotExists policy effects
41+
42+
The applicability of `AuditIfNotExists` and `DeployIfNotExists` policies is based off the entire `if` condition of the policy rule. When the `if` evaluates to false, the policy is not applicable.
43+
44+
## Applicability logic for resource provider modes
45+
46+
### Microsoft.Kubernetes.Data
47+
48+
The applicability of `Microsoft.Kubernetes.Data` policies is based off the entire `if` condition of the policy rule. When the `if` evaluates to false, the policy is not applicable.
49+
50+
### Microsoft.KeyVault.Data
51+
52+
Policies with mode `Microsoft.KeyVault.Data` are applicable if the `type` condition of the policy rule evaluates to true. The `type` refers to component type, such as:
53+
- Microsoft.KeyVault.Data/vaults/certificates
54+
- Microsoft.KeyVault.Data/vaults/keys
55+
- Microsoft.KeyVault.Data/vaults/secrets
56+
57+
### Microsoft.Network.Data
3958

40-
The applicability of AuditIfNotExists and DeployIfNotExists policies is based off the entire `if` condition of the policy rule. When the `if` evaluates to false, the policy is not applicable.
59+
Policies with mode `Microsoft.Network.Data` are applicable if the `type` and `name` conditions of the policy rule evaluate to true. The `type` refers to component type:
60+
- Microsoft.Network/virtualNetworks
4161

4262
## Next steps
4363

articles/governance/policy/how-to/get-compliance-data.md

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,18 @@ For details and steps, see
238238

239239
## How compliance works
240240

241-
In an assignment, a resource is **Non-compliant** if it doesn't follow policy or initiative rules
242-
and isn't _exempt_. The following table shows how different policy effects work with the condition
243-
evaluation for the resulting compliance state:
241+
When initiative or policy definitions are assigned and evaluated, resulting compliance states are determined based on conditions in the policy rule and resources' adherence to those requirements.
242+
243+
Azure Policy supports the following compliance states:
244+
- Non-compliant
245+
- Compliant
246+
- Conflict
247+
- Exempted
248+
- Unknown (preview)
249+
250+
### Compliant and non-compliant states
251+
252+
In an assignment, a resource is **non-compliant** if it is applicable to the policy assignment and does not adhere to conditions in the policy rule. The following table shows how different policy effects work with the condition evaluation for the resulting compliance state:
244253

245254
| Resource State | Effect | Policy Evaluation | Compliance State |
246255
| --- | --- | --- | --- |
@@ -254,6 +263,8 @@ evaluation for the resulting compliance state:
254263
> existence condition to be FALSE to be non-compliant. When TRUE, the IF condition triggers
255264
> evaluation of the existence condition for the related resources.
256265

266+
#### Example
267+
257268
For example, assume that you have a resource group - ContsoRG, with some storage accounts
258269
(highlighted in red) that are exposed to public networks.
259270

@@ -270,6 +281,14 @@ audits the three non-compliant storage accounts, consequently changing their sta
270281
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.
271282
:::image-end:::
272283

284+
#### Understand non-compliance
285+
286+
When a resource is determined to be **non-compliant**, there are many possible reasons. To determine
287+
the reason a resource is **non-compliant** or to find the change responsible, see
288+
[Determine non-compliance](./determine-non-compliance.md).
289+
290+
### Other compliance states
291+
273292
Besides **Compliant** and **Non-compliant**, policies and resources have four other states:
274293

275294
- **Exempt**: The resource is in scope of an assignment, but has a
@@ -280,11 +299,7 @@ Besides **Compliant** and **Non-compliant**, policies and resources have four ot
280299
- **Not registered**: The Azure Policy Resource Provider hasn't been registered or the account
281300
logged in doesn't have permission to read compliance data.
282301

283-
Azure Policy uses the **type**, **name**, or **kind** fields in the definition to determine whether
284-
a resource is a match. When the resource matches, it's considered applicable and has a status of
285-
either **Compliant**, **Non-compliant**, or **Exempt**. If either **name** or **kind** is the only
286-
property in the definition, then all included and non-exempt resources are considered applicable and
287-
are evaluated.
302+
Azure Policy relies on several factors to determine whether a resource is considered [applicable](../concepts/policy-applicability.md), then to determine its compliance state.
288303

289304
The compliance percentage is determined by dividing **Compliant**, **Exempt**, and **Unknown** resources by _total
290305
resources_. _Total resources_ is defined as the sum of the **Compliant**, **Non-compliant**,
@@ -300,7 +315,29 @@ The overall resource compliance is 95% (19 out of 20).
300315
> pages in portal are different for enabled initiatives. For more information, see
301316
> [Regulatory Compliance](../concepts/regulatory-compliance.md)
302317

303-
## Portal
318+
### Compliance roll up
319+
320+
There are several ways to view aggregated compliance results:
321+
322+
| Aggregate scope | Factors determining resulting compliance state |
323+
| --- | --- |
324+
| Initiative | All policies within |
325+
| Initiative group or control | All policies within |
326+
| Policy | All applicable resources |
327+
| Resource | All applicable policies |
328+
329+
So how is the aggregate compliance state determined if multiple resources or policies have different compliance states themselves? This is done by ranking each compliance state so that one "wins" over another in this situation. The rank order is:
330+
1. Non-compliant
331+
1. Compliant
332+
1. Conflict
333+
1. Exempted
334+
1. Unknown (preview)
335+
336+
This means that if there are both non-compliant and compliant states, the rolled up aggregate would be non-compliant, and so on. Let's look at an example.
337+
338+
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 will only show as exempt for the entire initiative if it is exempt from, or has unknown compliance to, every other single applicable policy in that initiative. On the other extreme, if the resource is non-compliant to at least one applicable policy in the initiative, it will have an overall compliance state of non-compliant, regardless of the remaining applicable policies.
339+
340+
## Compliance reporting through Azure Portal
304341

305342
The Azure portal showcases a graphical experience of visualizing and understanding the state of
306343
compliance in your environment. On the **Policy** page, the **Overview** option provides details for
@@ -323,9 +360,6 @@ resources for the current assignment. The tab defaults to **Non-compliant**, but
323360
Events (append, audit, deny, deploy, modify) triggered by the request to create a resource are shown
324361
under the **Events** tab.
325362

326-
> [!NOTE]
327-
> For an AKS Engine policy, the resource shown is the resource group.
328-
329363
:::image type="content" source="../media/getting-compliance-data/compliance-events.png" alt-text="Screenshot of the Events tab on Compliance Details page." border="false":::
330364

331365
<a name="component-compliance"></a>
@@ -344,13 +378,10 @@ log provides additional context and information about those events.
344378

345379
:::image type="content" source="../media/getting-compliance-data/compliance-activitylog.png" alt-text="Screenshot of the Activity Log for Azure Policy activities and evaluations." border="false":::
346380

347-
### Understand non-compliance
348-
349-
When a resource is determined to be **non-compliant**, there are many possible reasons. To determine
350-
the reason a resource is **non-compliant** or to find the change responsible, see
351-
[Determine non-compliance](./determine-non-compliance.md).
381+
> [!NOTE]
382+
> Compliance results can be exported from the Portal through [Azure Resource Graph queries](../samples/resource-graph-samples.md).
352383

353-
## Command line
384+
## Compliance reporting through the command line
354385

355386
The same information available in the portal can be retrieved with the REST API (including with
356387
[ARMClient](https://github.com/projectkudu/ARMClient)), Azure PowerShell, and Azure CLI. For full
@@ -832,7 +863,7 @@ PS> (Get-AzADUser -ObjectId {principalOid}).DisplayName
832863
Trent Baker
833864
```
834865

835-
## Azure Monitor logs
866+
## Compliance reporting through Azure Monitor logs
836867

837868
If you have a [Log Analytics workspace](../../../azure-monitor/logs/log-query-overview.md) with
838869
`AzureActivity` from the

0 commit comments

Comments
 (0)