|
1 | 1 | ---
|
2 | 2 | title: Azure Policy extension for Visual Studio Code
|
3 | 3 | description: Learn how to use the Azure Policy extension for Visual Studio Code to look up Azure Resource Manager aliases.
|
4 |
| -ms.date: 10/14/2020 |
| 4 | +ms.date: 10/20/2020 |
5 | 5 | ms.topic: how-to
|
6 | 6 | ---
|
7 | 7 | # Use Azure Policy extension for Visual Studio Code
|
8 | 8 |
|
9 |
| -> Applies to Azure Policy extension version **0.0.21** and newer |
| 9 | +> Applies to Azure Policy extension version **0.1.0** and newer |
10 | 10 |
|
11 | 11 | Learn how to use the Azure Policy extension for Visual Studio Code to look up
|
12 |
| -[aliases](../concepts/definition-structure.md#aliases) and review resources and policies. First, |
13 |
| -we'll describe how to install the Azure Policy extension in Visual Studio Code. Then we'll walk |
14 |
| -through how to look up aliases. |
| 12 | +[aliases](../concepts/definition-structure.md#aliases), review resources and policies, export |
| 13 | +objects, and evaluate policy definitions. First, we'll describe how to install the Azure Policy |
| 14 | +extension in Visual Studio Code. Then we'll walk through how to look up aliases. |
15 | 15 |
|
16 | 16 | Azure Policy extension for Visual Studio Code can be installed on all platforms that are supported
|
17 | 17 | by Visual Studio Code. This support includes Windows, Linux, and macOS.
|
@@ -192,6 +192,64 @@ the treeview, the Azure Policy extension opens the JSON that represents the poli
|
192 | 192 | all its Resource Manager property values. The extension can validate the opened Azure Policy JSON
|
193 | 193 | schema.
|
194 | 194 |
|
| 195 | +## Export objects |
| 196 | + |
| 197 | +Objects from your subscriptions can be exported to a local JSON file. In either the **Resources** or |
| 198 | +**Policies** pane, hover over or select an exportable object. At the end of the highlighted row, |
| 199 | +select the save icon and select a folder to save that resources JSON. |
| 200 | + |
| 201 | +The following objects can be exported locally: |
| 202 | + |
| 203 | +- Resources pane |
| 204 | + - Resource groups |
| 205 | + - Individual resources (either in a resource group or under a Resource Provider) |
| 206 | +- Policies pane |
| 207 | + - Policy assignments |
| 208 | + - Built-in policy definitions |
| 209 | + - Custom policy definitions |
| 210 | + - Initiatives |
| 211 | + |
| 212 | +## On-demand evaluation scan |
| 213 | + |
| 214 | +An evaluation scan can be started with the Azure Policy extension for Visual Studio Code. To start |
| 215 | +an evaluation, select and pin each of the following objects: a resource, a policy definition, and a |
| 216 | +policy assignment. |
| 217 | + |
| 218 | +1. To pin each object, find it in either the **Resources** pane or the **Policies** pane and select |
| 219 | + the pin to an edit tab icon. Pinning an object adds it to the **Evaluation** pane of the |
| 220 | + extension. |
| 221 | +1. In the **Evaluation** pane, select one of each object and use the select for evaluation icon to |
| 222 | + mark it as included in the evaluation. |
| 223 | +1. At the top of the **Evaluation** pane, select the run evaluation icon. A new pane in Visual |
| 224 | + Studio Code opens with the resulting evaluation details in JSON form. |
| 225 | + |
| 226 | +> [!NOTE] |
| 227 | +> If the selected policy definition is either an |
| 228 | +> [AuditIfNotExists](../concepts/effects.md#auditifnotexists) or |
| 229 | +> [DeployIfNotExists](../concepts/effects.md#deployifnotexists), in the **Evaluation** pane use the |
| 230 | +> plus icon to selected a _related_ resource for the existence check. |
| 231 | +
|
| 232 | +The evaluation results provide information about the policy definition and policy assignment along |
| 233 | +with the **policyEvaluations.evaluationResult** property. The output looks similar to the following |
| 234 | +example: |
| 235 | + |
| 236 | +```json |
| 237 | +{ |
| 238 | + "policyEvaluations": [ |
| 239 | + { |
| 240 | + "policyInfo": { |
| 241 | + ... |
| 242 | + }, |
| 243 | + "evaluationResult": "Compliant", |
| 244 | + "effectDetails": { |
| 245 | + "policyEffect": "Audit", |
| 246 | + "existenceScope": "None" |
| 247 | + } |
| 248 | + } |
| 249 | + ] |
| 250 | +} |
| 251 | +``` |
| 252 | + |
195 | 253 | ## Sign out
|
196 | 254 |
|
197 | 255 | From the menu bar, go to **View** > **Command Palette**, and then enter **Azure: Sign Out**.
|
|
0 commit comments