> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/virtual-machine-scanning/azure-virtual-machine-scanning-setup.md).

# Azure Virtual Machine Scanning Setup

{% hint style="info" %}
This functionality is available for **Pro** and **Advanced** plans only. [Contact us](https://www.aikido.dev/contact) for more information.
{% endhint %}

### Why should I scan my virtual machines? <a href="#why-should-i-scan-my-virtual-machines" id="why-should-i-scan-my-virtual-machines"></a>

With virtual machine scanning, Aikido scans the disks of your virtual machines for vulnerable packages and outdated runtimes.

### Prerequisites

You'll need an Entra ID app registration with a client secret. If you've already connected your Azure cloud to Aikido for cloud scanning, you can reuse that same app registration, no need to create a new one. Otherwise, set that up first via [Connect your Azure cloud](https://help.aikido.dev/cloud-scanning/connect-your-cloud/azure/connect-azure-cloud-account-to-aikido).

### Create a custom role <a href="#getting-started" id="getting-started"></a>

Aikido uses a custom Azure role scoped to the minimum permissions needed to scan your virtual machines.

{% stepper %}
{% step %}

### Go to Access control (IAM)

Navigate to **Subscriptions** (or your **management group**), find the relevant scope for your virtual machines, and click **Access control (IAM)**.
{% endstep %}

{% step %}

### Add a custom role

Click **Add**, then **Add custom role**.
{% endstep %}

{% step %}

### Choose your scope

Decide whether the role should be assignable at **subscription level** or **management group level**:

* **Single subscription:** covers VMs in one subscription only.
* **Management group:** covers all subscriptions underneath it, useful if your VMs are spread across multiple subscriptions.

{% hint style="info" %}
For management group scope, you don't need to look up a separate ID. Use your **Directory (tenant) ID**, the same one from your app registration overview page. This maps to your organization's root management group.
{% endhint %}
{% endstep %}

{% step %}

### Paste the role JSON

Go to the **JSON** tab and click **Edit**. Paste the role definition below.

Set `assignableScopes` based on the scope you chose:

For a single subscription:

```json
"assignableScopes": [
  "/subscriptions/<your-subscription-id>"
]
```

For a management group:

```json
"assignableScopes": [
  "/providers/Microsoft.Management/managementGroups/<your-directory-tenant-id>"
]
```

Full role definition:

```json
{
  "properties": {
    "roleName": "Aikido VM Scanner",
    "description": "",
    "assignableScopes": [
      "<insert scope from above>"
    ],
    "permissions": [
      {
        "actions": [
          "Microsoft.Compute/virtualMachines/read",
          "Microsoft.Compute/disks/beginGetAccess/action",
          "Microsoft.Compute/disks/endGetAccess/action",
          "Microsoft.Compute/disks/read",
          "Microsoft.Compute/snapshots/read",
          "Microsoft.Compute/snapshots/write",
          "Microsoft.Compute/snapshots/delete",
          "Microsoft.Compute/snapshots/beginGetAccess/action",
          "Microsoft.Compute/snapshots/endGetAccess/action",
          "Microsoft.Authorization/roleAssignments/read"
        ],
        "notActions": [],
        "dataActions": [],
        "notDataActions": []
      }
    ]
  }
}
```

Click **Save**.
{% endstep %}

{% step %}

### Review and create

At the bottom, click **Review + assign**, then **Create**.
{% endstep %}
{% endstepper %}

### Assign the role to your app registration

{% stepper %}
{% step %}

### Go back to Access control (IAM)

Navigate to the same scope (subscription or management group) and click **Access control (IAM)**.
{% endstep %}

{% step %}

### Add a role assignment

Go to the **Role assignments** tab, click **Add**, then **Add role assignment**.
{% endstep %}

{% step %}

### Select the custom role

In the **Role** tab, search for and select the **Aikido VM Scanner** role, then click **Next**.
{% endstep %}

{% step %}

### Assign it to your app registration

Leave **Assign access to** on its default value. Click **Select members**, search for your app registration name (e.g. "AikidoSecurity"), and select it. Click **Select**, then **Review + assign** twice.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
Your app registration now has the permissions it needs to scan your Azure virtual machines.
{% endhint %}

### VM grouping

To optimize scanning efficiency, Aikido groups certain Azure VMs and scans only one instance from each group. Grouping works as follows:

* **Virtual Machine Scale Sets (VMSS)**: All VMs that belong to the same VMSS are shown as a single VM group in Aikido. The VM group's name matches the VMSS identifier.
* **No grouping**: VMs that aren't part of a VMSS are treated as standalone VMs and scanned individually.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.aikido.dev/virtual-machine-scanning/azure-virtual-machine-scanning-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
