{
    "id": "1eafb23e-407e-407c-9b34-561a8bd4a099",
    "name": "Implement a Custom ARM Policy",
    "slug": "implement-a-custom-arm-policy",
    "status": "published",
    "lab_type": "azure",
    "is_sample": false,
    "duration_in_seconds": 1200,
    "metadata": {},
    "session": null,
    "company": "a491bc32-c056-4946-9169-cc053387bada",
    "created": "2020-08-11T12:14:06.209019Z",
    "modified": "2023-10-03T18:58:31.049578Z",
    "is_beta": false,
    "lab_objectives": [],
    "main_learning_area": null,
    "learning_areas": [],
    "categories": [],
    "tags": [],
    "difficulty": null,
    "is_web_access": false,
    "is_lab_experience": false,
    "is_featured": false,
    "cve": null,
    "severity": null,
    "year": null,
    "classification": null,
    "is_trackable": false,
    "cpe_credits": null,
    "is_skill_check": false,
    "external_url": "https://portal.azure.com/",
    "solution_video": "84a64488-67c6-466e-8c67-e85c0e98c3dd",
    "explanation_video": null,
    "description": "# Task: Implement a Custom ARM Policy\n\n## Video: Policies and Initiatives in Action\n\n**Estimated time:** 15 minutes\n\n## Goal\n\nCreate a custom ARM Policy that requires a specific Tag be applied to all resources provisioned in a resource group.\n\n## Pre-requisites\n\n1. Azure subscription\n2. Azure AD tenant\n\n    *Completing previous tasks will meet pre-requisites.*\n\n## Requirements\n\n1. Create a custom ARM policy that requires a specific tag\n2. Assign the policy to a resource group\n3. Validate the policy\n\n---\n\n## Requirement 1: Create custom ARM policy\n\nCreate a new policy named **DemoPolicy** that requires a **costCenter** tag.\n\n- Use the following policy rule:\n\n````json\n{\n  \"if\": {\n      \"not\": {\n          \"field\": \"tags\",\n          \"containsKey\": \"costCenter\"\n      }\n  },\n  \"then\": {\n      \"effect\": \"deny\"\n  }\n}\n````\n\n## Requirement 2: Assign the policy to a resource group\n\nNow you will create a new resource group and assign the policy to the resource group.  To complete this requirements:\n\n- Provision a new resource group named **task-policy**.\n- Assign the **DemoPolicy** policy to the **task-policy** resource group.\n\n## Requirement 3: Validate the policy\n\nFinally, you will test the policy.  You will confirm that resources without the **costCenter** tag cannot be provisioned in the **task-policy** resource group, and those with the tag can.  To complete the requirement:\n\n- Attempt to provision a route table named **demoroute** in the **task-policy** resource group without a **costCenter** tag. This should fail.\n- Attempt to provision a virtual machine named **demovm** in the **task-policy** resource group with a **costCenter** tag. This should succeed.\n\n## Cleanup\n\n- Delete the **task-policy** resource group.\n- Delete the **DemoPolicy** ARM policy.\n\n## Solution\n\nHaving trouble completing this task?  View the demonstration video to see how to do it.",
    "description_html": "<h1>Task: Implement a Custom ARM Policy</h1>\n<h2>Video: Policies and Initiatives in Action</h2>\n<p><strong>Estimated time:</strong> 15 minutes</p>\n<h2>Goal</h2>\n<p>Create a custom ARM Policy that requires a specific Tag be applied to all resources provisioned in a resource group.</p>\n<h2>Pre-requisites</h2>\n<ol>\n<li>Azure subscription</li>\n<li>\n<p>Azure AD tenant</p>\n<p><em>Completing previous tasks will meet pre-requisites.</em></p>\n</li>\n</ol>\n<h2>Requirements</h2>\n<ol>\n<li>Create a custom ARM policy that requires a specific tag</li>\n<li>Assign the policy to a resource group</li>\n<li>Validate the policy</li>\n</ol>\n<hr />\n<h2>Requirement 1: Create custom ARM policy</h2>\n<p>Create a new policy named <strong>DemoPolicy</strong> that requires a <strong>costCenter</strong> tag.</p>\n<ul>\n<li>Use the following policy rule:</li>\n</ul>\n<pre class=\"codehilite\"><code class=\"language-json\">{\n  \"if\": {\n      \"not\": {\n          \"field\": \"tags\",\n          \"containsKey\": \"costCenter\"\n      }\n  },\n  \"then\": {\n      \"effect\": \"deny\"\n  }\n}</code></pre>\n\n<h2>Requirement 2: Assign the policy to a resource group</h2>\n<p>Now you will create a new resource group and assign the policy to the resource group.  To complete this requirements:</p>\n<ul>\n<li>Provision a new resource group named <strong>task-policy</strong>.</li>\n<li>Assign the <strong>DemoPolicy</strong> policy to the <strong>task-policy</strong> resource group.</li>\n</ul>\n<h2>Requirement 3: Validate the policy</h2>\n<p>Finally, you will test the policy.  You will confirm that resources without the <strong>costCenter</strong> tag cannot be provisioned in the <strong>task-policy</strong> resource group, and those with the tag can.  To complete the requirement:</p>\n<ul>\n<li>Attempt to provision a route table named <strong>demoroute</strong> in the <strong>task-policy</strong> resource group without a <strong>costCenter</strong> tag. This should fail.</li>\n<li>Attempt to provision a virtual machine named <strong>demovm</strong> in the <strong>task-policy</strong> resource group with a <strong>costCenter</strong> tag. This should succeed.</li>\n</ul>\n<h2>Cleanup</h2>\n<ul>\n<li>Delete the <strong>task-policy</strong> resource group.</li>\n<li>Delete the <strong>DemoPolicy</strong> ARM policy.</li>\n</ul>\n<h2>Solution</h2>\n<p>Having trouble completing this task?  View the demonstration video to see how to do it.</p>",
    "tasks": "",
    "tasks_html": "",
    "published_date": "2020-06-23T22:51:02Z",
    "solutions": "",
    "solutions_html": "",
    "flags": [],
    "min_points_to_pass": null,
    "access_type": "default",
    "user_status": "unstarted",
    "user_lab_status": null,
    "user_status_modified": null,
    "user_flags": []
}