{
    "id": "991e6f3c-7078-455e-a44f-c5bd78b0647f",
    "name": "Define and Assign a Custom Initiative",
    "slug": "define-and-assign-a-custom-initiative",
    "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:09.394739Z",
    "modified": "2023-10-03T18:58:52.846853Z",
    "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": "d35e629b-cb31-49dd-9d23-982ebc07f58e",
    "explanation_video": null,
    "description": "# Task: Define and Assign a Custom Initiative\n\n## Video: Resource Policies and Initiatives in Action\n\n**Estimated time:** 15 minutes\n\n## Goal\n\nThe goal of this task is to create a custom policy and a custom initiative.  The policy is created from the command line using a custom json definition file.  The custom initiative then combines the custom policy with a built-in policy.\n\n*Note: If you are creating a custom purpose-built policy, it is likely easier to add all settings in a single policy rather than creating a separate policy and initiative.  Also, the policy that you create for this task can be implemented with a built-in policy but is used to provide a simple example of a custom policy.*\n\n## Pre-requisites\n\n1. Non-production Azure subscription\n2. An Azure AD cloud user named **tasks** for testing access\n\n## Requirements\n\n1. Requirement 1: Define a custom policy\n2. Requirement 2: Define a custom initiative\n3. Requirement 3: Apply a custom initiative\n4. Requirement 4: Test a custom initiative\n\n## Pre-requisite setup\n\nYou can create a new Azure AD user from the bash cloud shell by running the following command (substitute your values for the domain name and password):\n\n```bash\naz ad user create --display-name tasks --password <your password> --user-principal-name tasks@<your domain> --force-change-password-next-login false\n```\n\nExample\n\n```bash\naz ad user create --display-name tasks --password B@dPa55word! --user-principal-name tasks@inedemos.onmicrosoft.com --force-change-password-next-login false\n```\n\n## Requirement 1: Define a custom policy\n\nTo complete this requirement you must create a custom policy named **restrictedVM**.  The policy must meet the following requirements:\n\n- Restrict virtual machine size to **Standard_D2S_V3**.\n- Allow any other types of resources.\n\nThe json for the policy definition is as follows:\n\n```json\n{\n    \"if\": {\n        \"allof\": [\n            {\n                \"field\": \"type\",\n                \"equals\":\"Microsoft.Compute/VirtualMachines\"\n            },\n            {\n                \"not\":{\n                    \"field\":\"Microsoft.Compute/virtualMachines/sku.name\",\n                    \"in\":[\n                        \"Standard_D2s_v3\"\n                    ]\n                }\n            }\n        ]\n    },\n    \"then\": {\n        \"effect\": \"deny\"\n    }\n}\n```\n\n## Requirement 2: Define a custom initiative\n\nTo fulfill requirement 2, you must create an initiative named **location-and-vm** in your Azure subscription.  Use the **General** category. The initiative must apply the following policies:\n    - The **restrictedVM** custom policy.\n    - The **Allowed Locations** built-in policy.\n      - *Set the location restriction to EastUS.*\n\n## Requirement 3: Apply a custom initiative\n\nFor this requirement you must create a resource group named **task-policy-rg** in the East US region.  Apply the **location-and-vm** initiative to the resource group.\n\n## Requirement 4: Test a custom initiative\n\nFinally, you will test the initiative.  Attempt to create the following in the **task-policy-rg** resource group:\n\n- A network security group named **policy-nsg** in the East US region.\n- A storage account with a unique name in the West US region.\n- A Standard_D2S_V3 Ubuntu 18.04 virtual machine named **policy-linux-vm** in the EastUS region. *(Choose valid options or defaults for all other settings)*.\n- A Standard_A2 Windows 2016 virtual machine named **policy-win-vm** in the EastUS region. *(Choose valid options or defaults for all other settings)*.\n\n## Cleanup\n\nWhen you have finished this task, delete the **task-policy-rg** resource group, the **location-and-vm** initiative, and the **restrictedVM** custom policy.",
    "description_html": "<h1>Task: Define and Assign a Custom Initiative</h1>\n<h2>Video: Resource Policies and Initiatives in Action</h2>\n<p><strong>Estimated time:</strong> 15 minutes</p>\n<h2>Goal</h2>\n<p>The goal of this task is to create a custom policy and a custom initiative.  The policy is created from the command line using a custom json definition file.  The custom initiative then combines the custom policy with a built-in policy.</p>\n<p><em>Note: If you are creating a custom purpose-built policy, it is likely easier to add all settings in a single policy rather than creating a separate policy and initiative.  Also, the policy that you create for this task can be implemented with a built-in policy but is used to provide a simple example of a custom policy.</em></p>\n<h2>Pre-requisites</h2>\n<ol>\n<li>Non-production Azure subscription</li>\n<li>An Azure AD cloud user named <strong>tasks</strong> for testing access</li>\n</ol>\n<h2>Requirements</h2>\n<ol>\n<li>Requirement 1: Define a custom policy</li>\n<li>Requirement 2: Define a custom initiative</li>\n<li>Requirement 3: Apply a custom initiative</li>\n<li>Requirement 4: Test a custom initiative</li>\n</ol>\n<h2>Pre-requisite setup</h2>\n<p>You can create a new Azure AD user from the bash cloud shell by running the following command (substitute your values for the domain name and password):</p>\n<pre class=\"codehilite\"><code class=\"language-bash\">az ad user create --display-name tasks --password &lt;your password&gt; --user-principal-name tasks@&lt;your domain&gt; --force-change-password-next-login false</code></pre>\n\n<p>Example</p>\n<pre class=\"codehilite\"><code class=\"language-bash\">az ad user create --display-name tasks --password B@dPa55word! --user-principal-name tasks@inedemos.onmicrosoft.com --force-change-password-next-login false</code></pre>\n\n<h2>Requirement 1: Define a custom policy</h2>\n<p>To complete this requirement you must create a custom policy named <strong>restrictedVM</strong>.  The policy must meet the following requirements:</p>\n<ul>\n<li>Restrict virtual machine size to <strong>Standard_D2S_V3</strong>.</li>\n<li>Allow any other types of resources.</li>\n</ul>\n<p>The json for the policy definition is as follows:</p>\n<pre class=\"codehilite\"><code class=\"language-json\">{\n    \"if\": {\n        \"allof\": [\n            {\n                \"field\": \"type\",\n                \"equals\":\"Microsoft.Compute/VirtualMachines\"\n            },\n            {\n                \"not\":{\n                    \"field\":\"Microsoft.Compute/virtualMachines/sku.name\",\n                    \"in\":[\n                        \"Standard_D2s_v3\"\n                    ]\n                }\n            }\n        ]\n    },\n    \"then\": {\n        \"effect\": \"deny\"\n    }\n}</code></pre>\n\n<h2>Requirement 2: Define a custom initiative</h2>\n<p>To fulfill requirement 2, you must create an initiative named <strong>location-and-vm</strong> in your Azure subscription.  Use the <strong>General</strong> category. The initiative must apply the following policies:\n    - The <strong>restrictedVM</strong> custom policy.\n    - The <strong>Allowed Locations</strong> built-in policy.\n      - <em>Set the location restriction to EastUS.</em></p>\n<h2>Requirement 3: Apply a custom initiative</h2>\n<p>For this requirement you must create a resource group named <strong>task-policy-rg</strong> in the East US region.  Apply the <strong>location-and-vm</strong> initiative to the resource group.</p>\n<h2>Requirement 4: Test a custom initiative</h2>\n<p>Finally, you will test the initiative.  Attempt to create the following in the <strong>task-policy-rg</strong> resource group:</p>\n<ul>\n<li>A network security group named <strong>policy-nsg</strong> in the East US region.</li>\n<li>A storage account with a unique name in the West US region.</li>\n<li>A Standard_D2S_V3 Ubuntu 18.04 virtual machine named <strong>policy-linux-vm</strong> in the EastUS region. <em>(Choose valid options or defaults for all other settings)</em>.</li>\n<li>A Standard_A2 Windows 2016 virtual machine named <strong>policy-win-vm</strong> in the EastUS region. <em>(Choose valid options or defaults for all other settings)</em>.</li>\n</ul>\n<h2>Cleanup</h2>\n<p>When you have finished this task, delete the <strong>task-policy-rg</strong> resource group, the <strong>location-and-vm</strong> initiative, and the <strong>restrictedVM</strong> custom policy.</p>",
    "tasks": "",
    "tasks_html": "",
    "published_date": "2020-04-07T18:00:00Z",
    "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": []
}