In this lab you will learn to use Azure Policy to govern resource deployment within Azure.
- 30 minutes
- Launch the Azure Policy service in the Azure portal by selecting All services, then searching for and selecting Policy.
- Select Assignments on the left side of the Azure Policy page. An assignment is a policy that has been assigned to take place within a specific scope.
- Select Assign Policy from the top of the Policy - Assignments page.
- On the Assign Policy page, set the Scope by selecting the ellipsis and then select the Azure pass subscription. Select the marketplace resource group that you have created. A scope determines what resources or grouping of resources the policy assignment gets enforced on. Then use the Select button at the bottom of the Scope page.
- Select the Policy definition ellipsis to open the list of available definitions. Azure Policy comes with built-in policy definitions you can use. Search location.
- Select Allowed locations. Select Add.
- Select Next twice to arrive at the Parameters tab.
- Select the Allowed locations drop-down, search US, and choose East US, East US 2, Central US, North Central, South Central US, West US, and West US 2.
- Select Review + create. Select Create.
- The Azure policy assignment will be deployed and enforced on the marketplace resource group.
-
Expand the portal's left navigation by clicking Show portal menu then click + Create a resource.
-
In the upper-right of the page, next to Popular Marketplace products, select See more in Marketplace.
-
To view only virtual machine offers, click Product Type near the top of the page, then select Virtual Machine.
-
You can also filter the results by pricing, operating system, publisher type, and publisher name. You can also select a category on the left of the page to further filter the results.
-
Select the Windows Server offer.
-
Many virtual machine offers have multiple plans, and they can be selected via the Plan dropdown. Select Windows Server 2022 Datacenter then click Create.
-
Enter the following information then click Review + create then Create.
-
Resource group: LabRG
-
Virtual machine name: Enter a unique name
-
Region: Canada Central
-
Username: demouser
-
Password/Confirm password: demo@pass123
-
-
Select Review + create.
-
You will get a message that the deployment has failed policy. Review the details to find that the failure was on the location chosen.
-
Return to the Basics tab and change the Region to US East. The deployment will succeed.
In this exercise, you learned to use Azure Policy to govern resource deployment within Azure.