When managing an Azure tenant, ensuring compliance and maintaining standards is crucial. One effective way to do this is by leveraging Azure policies. In this guide, we’re going to walk you through the process of applying an Azure policy, specifically one that requires a tag on resources. 

Introduction to Azure Policies

Azure policies are tools that help manage and enforce various rules within your Azure environment. They ensure that resource configurations align with your organization’s standards and requirements. In this tutorial, we’ll focus on creating a policy that mandates tagging resources with specific information, like who created them.

Step-by-Step Guide

1. Searching for the Policy Option 

Begin by navigating to the Azure portal and typing “Policy” in the search bar. This will lead you to the Policy service where you can view, create, and manage policies.

2. Navigating to Policy Definitions

Once in the Policy service, go to the “Definitions” section under “Authoring.” Here, you will find various predefined policy definitions and categories. 

3. Selecting the ‘Require a Tag’ Policy

Search for “require a tag” within the policy definitions. You will encounter policies such as “Require a tag for resource groups” and “Require a tag on resources.” For the scope of this guide, we will select “Require a tag on resources.”

4. Understanding Policy Variations

You might notice policies like “Require a tag” and “Require a tag and its value.” The primary difference is that the latter enforces not only the presence of a tag but also a specific value for that tag. For example, “Created by” could be a tag, and “John Doe” could be the required value.

5. Assigning the Policy

Select the “Require a tag on resources” policy and click on “Assign.” You’ll then enter a few details. For the policy definition, you’ll see “Require a tag on resources v1.” You can rename the policy if necessary.

6. Defining the Tag Parameter

Next, you’ll define parameters for the tag. In this example, we’ll use “Created by” as the tag. If you had chosen the policy that requires a specific value, you’d specify that here as well.

7. Setting Remediation Options

By default, the policy will apply only to newly created resources. To have it affect existing resources, you need to configure remediation settings, which might include deploying tasks or using a managed identity for automatic deployment.

8. Adding a Noncompliance Message

Specify a message that will be displayed if resources are non-compliant. For example, you can set the message to, “The resource is missing a Created by tag. Please add the tag and list your name as the creator of this resource.”

9. Creating the Policy

Click “Create” to finalize the assignment of the policy. Now, the policy should be active and visible under the “Assignments” section.

10. Testing the Policy

To verify, attempt to create a resource without the required tag. For instance, try creating a public IP address without any tags. During the validation process, you should see an error indicating that the resource is disallowed by the policy due to the missing “Created by” tag.

11. Complying with the Policy

Add the required “Created by” tag with your name and re-run the validation. Once all checks pass, you can successfully create the resource.

 

The Wrap Up

Azure policies are powerful tools that help maintain governance and compliance within your Azure environment. By following the steps in this guide, you can ensure that all resources are tagged appropriately, providing clarity and accountability. Additionally, explore other available policies to further secure and manage your Azure resources effectively. For more guidance, check out additional resources and posts on related topics.

This guide aims to provide a comprehensive walk-through of setting up and enforcing Azure policies, ensuring your environment remains well-organized and compliant.