Create a policy assignment to identify non-compliant resources in your Azure environment
The first step in understanding compliance in Azure is to identify the status of your resources. This quickstart steps you through the process of creating a policy assignment to identify virtual machines that are not using managed disks.
At the end of this process, you will successfully identify virtual machines that are not using managed disks. They are non-compliant with the policy assignment.
If you don't have an Azure subscription, create a free account before you begin.
Create a policy assignment
In this quickstart, you create a policy assignment and assign the Audit Virtual Machines without Managed Disks policy definition.
- Select Assignments on the left pane of the Azure Policy page.
Select Assign Policy from the top of the Assignments pane.
On the Assign Policy page, click next to Policy field to open the list of available definitions.
Azure Policy comes with already built-in policy definitions you can use. You see built-in policy definitions such as:
- Enforce tag and its value
- Apply tag and its value
Require SQL Server Version 12.0
For a complete list of all the available built-in polices, see Policy templates.
Search through your policy definitions to find the Audit VMs that do not use managed disks definition. Click on that policy and click Select.
Provide a display Name for the policy assignment. In this case, let’s use Audit VMs that do not use managed disks. You can also add an optional Description. The description provides details about how the policy assignment identifies all virtual machines that don't use managed disks.
Change the pricing tier to Standard to ensure that the policy gets applied to existing resources.
There are two pricing tiers within Azure Policy – Free and Standard. With the Free tier, you can only enforce policies on future resources, while with Standard, you can also enforce them on existing resources to better understand your compliance state. To read more about pricing, see Azure Policy pricing.
Select the Scope you would like the policy to be applied to. A scope determines what resources or grouping of resources the policy assignment gets enforced on. It could range from a subscription to resource groups.
Select the subscription (or resource group) you previously registered. In this example the Azure Analytics Capacity Dev subscription is used, but your options might differ. Click Select.
Leave Exclusions blank for now and then click Assign.
You’re now ready to identify non-compliant resources to understand the compliance state of your environment.
Identify non-compliant resources
Select Compliance on the left pane, and search for the policy assignment you created.
If there are any existing resources that are not compliant with this new assignment, they appear under Non-compliant resources.
When a condition is evaluated against your existing resources and found true, then those resources are marked as non-compliant with the policy. The preceding example image displays non-compliant resources. The following table shows how different policy actions work with the condition evaluation for the resulting compliance state. Although you don’t see the evaluation logic in the Azure portal, the compliance state results are shown. The compliance state result is either compliant or non-compliant.
|Resource||If Condition in the Policy Evaluates to||Action in the Policy||Compliance State|
Clean up resources
Other guides in this collection build upon this quickstart. If you plan to continue to work with subsequent tutorials, do not clean up the resources created in this quickstart. If you do not plan to continue, use the following steps to delete all resources created by this quickstart in the Azure portal.
- Select Assignments on the left pane.
Search for the assignment you created and then right-click it.
Select Delete Assignment.
In this quickstart, you assigned a policy definition to a scope. The policy definition ensures that all the resources in the scope are compliant and identifies which ones aren’t.
To learn more about assigning policies to ensure that future resources that get created are compliant, continue to the tutorial for: