Skip to content

Validating locally#

While preparing infrastructure code artifacts, Azure resources can be validated locally. PSRule for Azure can be installed locally on MacOS, Linux, and Windows for local validation.

Tip

If you haven't already, follow the instructions on Installing locally before continuing. If analyzing Azure resources from Bicep source files, complete Setup Bicep.

With Visual Studio Code#

Extension

An extension for Visual Studio Code is available for an integrated experience using PSRule for Azure. The Visual Studio Code extension includes a built-in PSRule: Run analysis task.

Built-in tasks shown in task list

To learn about tasks in Visual Studio Code see Integrate with External Tools via Tasks.

To use PSRule for Azure with the built-in PSRule: Run analysis task, insert the following into .vscode/tasks.json.

{
    "type": "PSRule",
    "problemMatcher": [
        "$PSRule"
    ],
    "label": "PSRule: Run analysis",
    "modules": [
        "PSRule.Rules.Azure"
    ],
    "presentation": {
        "clear": true,
        "panel": "dedicated"
    }
}

Example

A complete .vscode/tasks.json might look like the following:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "PSRule",
            "problemMatcher": [
                "$PSRule"
            ],
            "label": "PSRule: Run analysis",
            "modules": [
                "PSRule.Rules.Azure"
            ],
            "presentation": {
                "clear": true,
                "panel": "dedicated"
            }
        }
    ]
}

Last update: 2021-09-24