Skip to content

Commit 623bb03

Browse files
authored
Merge pull request #218138 from shanhix1/shannon-dev
Effect, Applicability, and Compliance docs updates
2 parents 0381362 + 00c9ac1 commit 623bb03

File tree

4 files changed

+101
-180
lines changed

4 files changed

+101
-180
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: 14 additions & 142 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's important to note that not all effects are interchangeable. Resource properties and logic in the policy rule can determine whether a certain effect is considered valid to the policy definition. For example, policy definitions with effect **AuditIfNotExists** require additional details in the policy rule that aren't 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+
Below is some 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** isn't interchangeable.
34+
- **Disabled** is interchangeable with any effect.
3635

3736
## Order of evaluation
3837

@@ -163,7 +162,7 @@ definitions as `constraintTemplate` is deprecated.
163162
template. See
164163
[Create policy definition from constraint template](../how-to/extension-for-vscode.md) to
165164
create a custom definition from an existing
166-
[Open Policy Agent](https://www.openpolicyagent.org/) (OPA) GateKeeper v3
165+
[Open Policy Agent](https://www.openpolicyagent.org/) (OPA) Gatekeeper v3
167166
[constraint template](https://open-policy-agent.github.io/gatekeeper/website/docs/howto/#constraint-templates).
168167
- **constraint** (deprecated)
169168
- Can't be used with `templateInfo`.
@@ -174,7 +173,7 @@ definitions as `constraintTemplate` is deprecated.
174173
- An _array_ of
175174
[Kubernetes namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
176175
to limit policy evaluation to.
177-
- An empty or missing value causes policy evaluation to include all namespaces, except those
176+
- An empty or missing value causes policy evaluation to include all namespaces not
178177
defined in _excludedNamespaces_.
179178
- **excludedNamespaces** (required)
180179
- An _array_ of
@@ -375,7 +374,7 @@ definitions as `constraintTemplate` is deprecated.
375374
template. See
376375
[Create policy definition from constraint template](../how-to/extension-for-vscode.md) to
377376
create a custom definition from an existing
378-
[Open Policy Agent](https://www.openpolicyagent.org/) (OPA) GateKeeper v3
377+
[Open Policy Agent](https://www.openpolicyagent.org/) (OPA) Gatekeeper v3
379378
[constraint template](https://open-policy-agent.github.io/gatekeeper/website/docs/howto/#constraint-templates).
380379
- **constraint** (optional)
381380
- Can't be used with `templateInfo`.
@@ -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.
@@ -821,7 +693,7 @@ The following operations are supported by Modify:
821693
- Add, replace, or remove resource tags. For tags, a Modify policy should have `mode` set to
822694
_Indexed_ unless the target resource is a resource group.
823695
- Add or replace the value of managed identity type (`identity.type`) of virtual machines and
824-
virtual machine scale sets.
696+
Virtual Machine Scale Sets.
825697
- Add or replace the values of certain aliases.
826698
- Use
827699
`Get-AzPolicyAlias | Select-Object -ExpandProperty 'Aliases' | Where-Object { $_.DefaultMetadata.Attributes -eq 'Modifiable' }`
@@ -876,11 +748,11 @@ needed for remediation and the **operations** used to add, update, or remove tag
876748
- Determines which policy definition "wins" if more than one policy definition modifies the same
877749
property or when the Modify operation doesn't work on the specified alias.
878750
- For new or updated resources, the policy definition with _deny_ takes precedence. Policy
879-
definitions with _audit_ skip all **operations**. If more than one policy definition has
751+
definitions with _audit_ skip all **operations**. If more than one policy definition has the effect
880752
_deny_, the request is denied as a conflict. If all policy definitions have _audit_, then none
881753
of the **operations** of the conflicting policy definitions are processed.
882-
- For existing resources, if more than one policy definition has _deny_, the compliance status
883-
is _Conflict_. If one or fewer policy definitions have _deny_, each assignment returns a
754+
- For existing resources, if more than one policy definition has the effect _deny_, the compliance status
755+
is _Conflict_. If one or fewer policy definitions have the effect _deny_, each assignment returns a
884756
compliance status of _Non-compliant_.
885757
- Available values: _audit_, _deny_, _disabled_.
886758
- Default value is _deny_.

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: timwarner-msft
88
---
99
# What is applicability in Azure Policy?
1010

11-
When a policy definition is assigned to a scope, Azure Policy determines which resources in that scope should be considered for compliance evaluation. A resource will only be assessed for compliance if it is considered **applicable** to the given policy assignment.
11+
When a policy definition is assigned to a scope, Azure Policy determines which resources in that scope should be considered for compliance evaluation. A resource will only be assessed for compliance if it's considered **applicable** to the given policy assignment.
1212

1313
Applicability is determined by several factors:
1414
- **Conditions** in the `if` block of the [policy rule](../concepts/definition-structure.md#policy-rule).
@@ -21,23 +21,43 @@ 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

2830
Following are special cases to the previously described applicability logic:
2931

3032
|Scenario |Result |
3133
|---------|---------|
32-
|Any invalid aliases in the `if` conditions |The policy is not applicable |
34+
|Any invalid aliases in the `if` conditions |The policy isn't applicable |
3335
|When the `if` conditions consist of only `kind` conditions |The policy is applicable to all resources |
3436
|When the `if` conditions consist of only `name` conditions |The policy is applicable to all resources |
3537
|When the `if` conditions consist of only `type` and `kind` or `type` and `name` conditions |Only type conditions are considered when deciding applicability |
36-
|When any conditions (including deployment parameters) include a `location` condition |Will not be applicable to subscriptions |
38+
|When any conditions (including deployment parameters) include a `location` condition |Won't be applicable to subscriptions |
39+
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 isn't 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 isn't 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
3756

38-
## Applicability logic for AuditIfNotExists and DeployIfNotExists policy effects
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

0 commit comments

Comments
 (0)