Skip to content

Commit f0188d1

Browse files
Merge pull request #234156 from divargas-msft/patch-5
[Doc-a-thon] Updating extensions-rmpolicy-howto-cli.md
2 parents fa59b50 + 7789f85 commit f0188d1

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

articles/virtual-machines/extensions/extensions-rmpolicy-howto-cli.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.custom: devx-track-azurecli
88
ms.author: gabsta
99
author: GabstaMSFT
1010
ms.collection: linux
11-
ms.date: 07/05/2022
11+
ms.date: 04/11/2023
1212
---
1313

1414
# Use Azure Policy to restrict extensions installation on Linux VMs
@@ -23,13 +23,9 @@ In order to restrict what extensions are available, you need to create a [rule](
2323

2424
This example demonstrates how to deny the installation of disallowed VM extensions by defining a rules file in Azure Cloud Shell. However, if you're working in Azure CLI locally, you can create a local file and replace the path (~/clouddrive) with the path to the file on your local file system.
2525

26-
In a [bash Cloud Shell](https://shell.azure.com/bash), type:
26+
1. In a [bash Cloud Shell](https://shell.azure.com/bash) create the file `~/clouddrive/azurepolicy.rules.json` using any text editor.
2727

28-
```bash
29-
vim ~/clouddrive/azurepolicy.rules.json
30-
```
31-
32-
Copy and paste the following `.json` data into the file.
28+
2. Copy and paste the following `.json` contents into the new file and save it.
3329

3430
```json
3531
{
@@ -55,21 +51,15 @@ Copy and paste the following `.json` data into the file.
5551
}
5652
```
5753

58-
When you're finished, press **Esc**, and then type **:wq** to save and close the file.
59-
6054
## Create a parameters file
6155

6256
You also need a [parameters](../../governance/policy/concepts/definition-structure.md#parameters) file that creates a structure for you to use for passing in a list of the unauthorized extensions.
6357

6458
This example shows you how to create a parameter file for Linux VMs in Cloud Shell.
6559

66-
In the bash Cloud Shell opened before type:
67-
68-
```bash
69-
vim ~/clouddrive/azurepolicy.parameters.json
70-
```
60+
1. In the bash Cloud Shell opened before, create the file ~/clouddrive/azurepolicy.parameters.json using any text editor.
7161

72-
Copy and paste the following `.json` data into the file.
62+
2. Copy and paste the following `.json` contents into the new file and save it.
7363

7464
```json
7565
{
@@ -83,8 +73,6 @@ Copy and paste the following `.json` data into the file.
8373
}
8474
```
8575

86-
When you're finished, press **Esc**, and then type **:wq** to save and close the file.
87-
8876
## Create the policy
8977

9078
A _policy definition_ is an object used to store the configuration that you would like to use. The policy definition uses the rules and parameters files to define the policy. Create the policy definition using [az policy definition create](/cli/azure/role/assignment).
@@ -133,10 +121,13 @@ Test the policy by creating a new VM and adding a new user.
133121
az vm create \
134122
--resource-group myResourceGroup \
135123
--name myVM \
136-
--image UbuntuLTS \
124+
--image myImage \
137125
--generate-ssh-keys
138126
```
139127

128+
> [!NOTE]
129+
> Replace `myResourceGroup`, `myVM` and `myImage` values accordingly.
130+
140131
Try to create a new user named **myNewUser** using the VM Access extension.
141132

142133
```azurecli-interactive
@@ -152,6 +143,7 @@ az vm user update \
152143
```azurecli-interactive
153144
az policy assignment delete --name 'not-allowed-vmextension-linux' --resource-group myResourceGroup
154145
```
146+
155147
## Remove the policy
156148

157149
```azurecli-interactive

0 commit comments

Comments
 (0)