> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/m/microsoft-azure-services.md).

# Microsoft Azure Services

This is the Microsoft Azure Services adapter (slug `azure-services`). OctoXLabs reads the resources of one Azure subscription through Azure Resource Manager and adds them as services. Virtual machines are one of many resource types, as listed under API endpoints called.

## Use cases

* **Inventory the Azure resources of a subscription.** Filter the services from this adapter.

```
Adapters = azure-services
```

* **Check what one Azure connection collected.**

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination               | Port | Protocol                           |
| ------------------- | ------------------------- | ---- | ---------------------------------- |
| OctoXLabs connector | login.microsoftonline.com | 443  | HTTPS (HTTP when Is Secure is off) |
| OctoXLabs connector | management.azure.com      | 443  | HTTPS (HTTP when Is Secure is off) |

If a proxy is set, requests go through it.

### Required permissions

The baseline states that the application must be granted read access to these resource paths:

| Scope or role | Permission                                                                                                                                                                                        | Needed for                   |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| Subscription  | Read on /Microsoft.Compute/virtualMachines                                                                                                                                                        | Virtual machines             |
| Subscription  | Read on /Microsoft.DesktopVirtualization/applicationGroups                                                                                                                                        | Application groups           |
| Subscription  | Read on /Microsoft.Storage/storageAccounts                                                                                                                                                        | Storage accounts             |
| Subscription  | Read on /Microsoft.Network/loadBalancers, azureFirewalls, networkSecurityGroups, privateEndpoints, publicIPAddresses, networkWatchers, virtualNetworks, privateDnsZones (and virtualNetworkLinks) | Network resources            |
| Subscription  | Read on /Microsoft.Web/containerApps and /Microsoft.Web/sites (functions)                                                                                                                         | Container apps and functions |
| Subscription  | Read on /Microsoft.ContainerRegistry/registries                                                                                                                                                   | Container registries         |
| Subscription  | Read on /Microsoft.ManagedIdentity/userAssignedIdentities                                                                                                                                         | Identities                   |
| Subscription  | Read on /resourcegroups                                                                                                                                                                           | Resource groups              |
| Subscription  | Read on /Microsoft.DBforPostgreSQL/flexibleServers                                                                                                                                                | PostgreSQL servers           |
| Subscription  | Read on /Microsoft.KeyVault/vaults                                                                                                                                                                | Key vaults                   |
| Subscription  | Read on /Microsoft.DevCenter                                                                                                                                                                      | Dev centers                  |
| Subscription  | Read on /Microsoft.Logic/workflows                                                                                                                                                                | Logic app workflows          |

A role such as Reader on the subscription covers these reads. The baseline does not name a built-in role.

## Create credentials in Azure

{% stepper %}
{% step %}

### Find the tenant ID

Sign in to the Azure portal, open **Azure Active Directory** and copy the **Tenant ID** from the **Basic information** section of the **Overview** page.
{% endstep %}

{% step %}

### Find the client ID

Open **Enterprise applications > All applications**, select the application you created, open **Properties** and copy the **Application ID**.
{% endstep %}

{% step %}

### Create a client secret

In the app registration, open **Certificates & secrets**, click **New client secret**, enter a description and an expiry, and copy the value at once. It is shown only once.
{% endstep %}

{% step %}

### Find the subscription ID

Under **Subscriptions**, copy the **Subscription ID** of the subscription to inventory.
{% endstep %}

{% step %}

### Grant read access

Give the application read access to the resource paths listed above.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter       | Required | Type    | Default                   | Description                                                                                                    |
| --------------- | -------- | ------- | ------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Login URL       | No       | String  | login.microsoftonline.com | Shown in the form. The code builds the token URL with `login.microsoftonline.com` and does not use this value. |
| Tenant ID       | Yes      | String  | None                      | Directory (tenant) ID.                                                                                         |
| Client ID       | Yes      | String  | None                      | Application ID.                                                                                                |
| Client Secret   | Yes      | String  | None                      | Client secret value.                                                                                           |
| Subscription ID | Yes      | String  | None                      | Subscription to read.                                                                                          |
| Proxy           | No       | String  | None                      | Proxy address, used as `http://<value>` for HTTP and HTTPS.                                                    |
| Is Secure       | No       | Boolean | True                      | Use HTTPS.                                                                                                     |
| Timeout         | No       | Integer | 30                        | Seconds to wait for an API response.                                                                           |

## Troubleshooting

| Error message                              | Cause                                                                                                                         | Fix                                           |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| Retry {n}/3 for {url} due to network error | A network error or timeout. This is logged as a warning.                                                                      | Check network access to management.azure.com. |
| Client error {status} for {url}            | Azure refused a request, for example when the application lacks read access. This is logged and the resource type is skipped. | Grant read access to that resource path.      |

## Change history
