Azure Policy helps enforce organizational standards and assess compliance at scale. Through its compliance dashboard, it provides an aggregated view to evaluate the overall state of the environment, with the ability to drill down to the per-resource, per-policy granularity. It also helps to bring your resources to compliance through bulk remediation for existing resources and automatic remediation for new resources.
Common use cases for Azure Policy include implementing governance for resource consistency, regulatory compliance, security, cost, and management. Policy definitions for these common use cases are already available in your Azure environment as built-ins to help you get started.
All Azure Policy data and objects are encrypted at rest.
Overview
Azure Policy evaluates Azure resources by comparing the properties of those resources to business rules. These business rules, described in JSON format, are policy definitions. To simplify management, several business rules can be grouped to form a policy initiative (sometimes called a policy set). Once your business rules have been formed, the policy definition or initiative is assigned to any scope of resources Azure supports, such as management groups, subscriptions, resource groups, or individual resources. The assignment applies to all resources within the Resource Manager scope of that assignment. Subscopes can be excluded if necessary.
Azure Policy uses a JSON format to form the logic the evaluation uses to determine whether a resource is compliant. Definitions include metadata and the policy rule. The defined rule can use functions, parameters, logical operators, conditions, and property aliases to match exactly the scenario you want. The policy rule determines which resources in the scope of the assignment get evaluated.
Understand evaluation outcomes
Resources are evaluated at specific times during the resource lifecycle, the policy assignment lifecycle, and for regular ongoing compliance evaluation. The following are the times or events that cause a resource to be evaluated:
A resource is created or updated within the scope of a policy assignment.
A policy or initiative is newly assigned to a scope.
A policy or initiative already assigned to a scope is updated.
During the standard compliance evaluation cycle, which occurs once every 24 hours.
Control the response to an evaluation
Business rules for handling non-compliant resources vary widely between organizations. Examples of how an organization wants the platform to respond to a non-compliant resource include:
Deny the resource change
Log the change to the resource
Alter the resource before the change
Alter the resource after the change
Deploy related compliant resources
Azure Policy makes each of these business responses possible through the application of effects. Effects are set in the policy rule portion of the policy definition.
Azure Policy and Azure RBAC
There are a few key differences between Azure Policy and Azure role-based access control (Azure RBAC). Azure Policy evaluates the state by examining properties on resources that are represented in Resource Manager and properties of some Resource Providers. Azure Policy doesn't restrict actions (also called operations). Azure Policy ensures that the resource state is compliant with your business rules without concern for who made the change or who has permission to make a change. Some Azure Policy resources, such as policy definitions, initiative definitions, and assignments, are visible to all users. This design enables transparency to all users and services for what policy rules are set in their environment.
Azure RBAC focuses on managing user actions at different scopes. If control of an action is required, then Azure RBAC is the correct tool to use. Even if an individual has access to perform an action, if the result is a non-compliant resource, Azure Policy still blocks the creation or update.
The combination of Azure RBAC and Azure Policy provides full-scope control in Azure.
Resources covered by Azure Policy
Azure Policy evaluates all Azure resources at or below the subscription level, including Arc-enabled resources. For certain resource providers such as guest configuration, Azure Kubernetes Service, and Azure Key Vault, there's a deeper integration for managing settings and objects.
Recommendations for managing policies
Here are a few pointers and tips to keep in mind:
Start with an audit effect instead of a deny effect to track the impact of your policy definition on the resources in your environment. If you have scripts already in place to autoscale your applications, setting a deny effect may hinder such automation tasks already in place.
Consider organizational hierarchies when creating definitions and assignments. We recommend creating definitions at higher levels, such as the management group or subscription level. Then, create the assignment at the next child level. If you create a definition for a management group, the assignment can be scoped down to a subscription or resource group within that management group.
We recommend creating and assigning initiative definitions even for a single policy definition. For example, you have policy definition policyDefA and create it under initiative definition initiativeDefC. If you create another policy definition later for policyDefB with goals similar to policyDefA, you can add it under initiativeDefC and track them together.
o Once you've created an initiative assignment, policy definitions added to the initiative also become part of that initiative's assignments.
o When an initiative assignment is evaluated, all policies within the initiative are also evaluated. If you need to evaluate a policy individually, it's better to not include it in an initiative.
Manage Azure Policy resources as code with manual reviews on changes to policy definitions, initiatives, and assignments.
Azure Policy objects
Policy definition
The journey of creating and implementing a policy in Azure Policy begins with creating a policy definition. Every policy definition has conditions under which it's enforced. It has a defined effect that takes place if the conditions are met.
In Azure Policy, we offer several built-in policies that are available by default. For example:
Allowed Storage Account SKUs (Deny)
Determines if a storage account being deployed is within a set of SKU sizes. Its effect is to deny all storage accounts that don't adhere to the set of defined SKU sizes.
Allowed Resource Type (Deny)
Defines the resource types that you can deploy. Its effect is to deny all resources that aren't part of this defined list.
Allowed Locations (Deny)
Restricts the available locations for new resources. Its effect is used to enforce your geo-compliance requirements.
Allowed Virtual Machine SKUs (Deny)
Specifies a set of virtual machine SKUs that you can deploy.
Add a tag to resources (Modify)
Applies a required tag and its default value if it's not specified by the deploy request.
Not allowed resource types (Deny)
Prevents a list of resource types from being deployed.
To implement these policy definitions (both built-in and custom definitions)
You'll need to assign them. You can assign any of these policies through the Azure portal, PowerShell, or Azure CLI.
Initiative definition
An initiative definition is a collection of policy definitions tailored toward achieving a singular overarching goal. Initiative definitions simplify managing and assigning policy definitions. They simplify by grouping a set of policies as one single item. For example, you could create an initiative titled Enable Monitoring in Microsoft Defender for Cloud, with the goal of monitoring all the available security recommendations in your Microsoft Defender for Cloud instance.
Under this initiative, you would have policy definitions such as:
Monitor unencrypted SQL Database in Microsoft Defender for Cloud - This is used to monitor unencrypted SQL databases and servers.
Monitor OS vulnerabilities in Microsoft Defender for Cloud - For monitoring servers that don't satisfy the configured baseline.
Monitor missing Endpoint Protection in Microsoft Defender for Cloud - For monitoring servers without an installed endpoint protection agent.
Like policy parameters, initiative parameters help simplify initiative management by reducing redundancy. Initiative parameters are parameters being used by the policy definitions within the initiative.
Assignments
An assignment is a policy definition or initiative that has been assigned to a specific scope. This scope could range from a management group to an individual resource. The term scope refers to all the resources, resource groups, subscriptions, or management groups to which the definition is assigned. Assignments are inherited by all child resources. This design means that a definition applied to a resource group is also applied to resources in that resource group. However, you can exclude a subscope from the assignment.
Comments