Learn how to implement an Azure Policy

Swetha Mudunuri
4 min readJul 8, 2023

--

🈯What is an Azure Policy?

💥Azure Policy is a collection of rules/guidelines you may implement to control how your cloud resources should be set up and utilized.

💥These rules may apply to a variety of things, including resource configurations, access restrictions, security settings, etc.

💥You can make sure that all the resources deployed in Azure adhere to a set of consistent standards by creating policies.

💥Azure Policy regularly assesses your resources in comparison to these policies to determine whether they adhere to the required standards.

💥If a resource does not adhere to the established rules, Azure Policy may take corrective measures or prohibit the resource from being created or updated.

💥It guarantees that your Azure environment stays compliant, secure, and aligned with your organization’s requirements.

Let’s learn how to Implement Azure Policy

  1. Resource Group Creation

💥Open https://portal.azure.com/ and open the PowerShell, which is available on the right side of Azure Portal.

Azure Portal

💥While launching Powershell, it gives the option to Create the storage.

💥In Powershell, enter the below command to create the resource in the “East US” region.

New-AzResourceGroup -Name CNLPolicy -Location 'East US'
Resource Group Creation

💥Run the below command to see the created resource group.

 Get-AzResourceGroup | format-table
Listing the Resource Group

2. Policy Creation

💥Create the Policy for the allowed Locations for the resources.

💥Search for Policy in the search bar as shown below.

Policy

💥On the Policy page, Under the Authorizing section, click on Definitions.

Definitions

💥Search for allowed locations, and click on allowed locations to create the policy.

Allowed Locations

💥Click on Assign.

Click Assign

💥On the Basics tab, enter the Subscription, Resource Group and Click Select.

Basic tab

💥You can change the Assignment name and Description as per the policy.

Basics Tab of Allowed Locations

💥Click Next, In the Parameters tab of allowed locations. From the drop-down list, choose either UK South or the other locations as per your requirements.

Parameters

💥Review the configuration and click on Create.

Create

💥Successfully created the Policy.

Successfully Created Policy 😍

3. Let’s test the policy that was created.

💥Search for Virtual Network and click on Create, Select the Resource Group and provide the Virtual network name and Region.

Virtual Network Creation

💥Unable to create the virtual network as the allowed location is UK South but the East US location was selected while creating the virtual network.

Failed Virtual Network creation 🙁

💥Changed the location to the UK South.

💥Successfully created the Virtual Network.

Successfully created Virtual Network 😀
Testing Completed

4. Clean up the resources that were created.

💥Use the below command to delete the resource group using the PowerShell command.

 Remove-AzResourceGroup -Name "CNLPolicy"

💥You can delete the storage group that was created for the Powershell from the portal.

💥To delete the Network Watcher, Go to Network Watcher — Click on Disable as shown below, confirm delete -type Yes.

Type Yes

💥Successfully cleaned up all the resources.

Thank you 😍😍😍

💥We came to the end of the blog, Stay tuned for the next blog to learn about Azure Security hands-on.

--

--

Swetha Mudunuri
Swetha Mudunuri

Written by Swetha Mudunuri

Cloud and Cybersecurity Professional

Responses (1)