> 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-defender-for-cloud-apps.md).

# Microsoft Defender for Cloud Apps

Microsoft Defender for Cloud Apps is the cloud access security broker (CASB) of Microsoft. OctoXLabs reads the user entities of your tenant through the Entities API and adds them to the user inventory.

## Use cases

* List the users that Defender for Cloud Apps knows.

```
Adapters = microsoft-defender-cloud-apps
```

* Find Defender for Cloud Apps users that belong to a given group.

```
Adapters = microsoft-defender-cloud-apps AND MembersOf ~ <group name>
```

## Before you begin

### Network

| Source              | Destination                                                                  | Port | Protocol |
| ------------------- | ---------------------------------------------------------------------------- | ---- | -------- |
| OctoXLabs connector | Tenant portal domain, format `<tenant>.<region>.portal.cloudappsecurity.com` | 443  | HTTPS    |

### Required permissions

| Scope or role                                  | Permission | Needed for           |
| ---------------------------------------------- | ---------- | -------------------- |
| Security Reader (Defender for Cloud Apps role) | Read       | Entities API (users) |

The API token inherits the permissions of the user that created it. Security Reader is the minimum. Global Admin and Security Admin also work. The Entities API is not available in the Microsoft 365 Cloud App Security variant. A full Microsoft Defender for Cloud Apps tenant is required.

## Create credentials in Microsoft Defender for Cloud Apps

{% stepper %}
{% step %}

### Find the tenant portal domain

In the Microsoft Defender Portal, open Settings > Cloud Apps > System > About. Copy the tenant URL without the protocol, for example `mytenant.eu2.portal.cloudappsecurity.com`.
{% endstep %}

{% step %}

### Open API tokens

Go to Settings > Cloud Apps > System > API tokens.
{% endstep %}

{% step %}

### Add a token

Select Add token, give it a name, and copy the generated token value.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                       | Required | Type    | Default | Description                                          |
| ------------------------------- | -------- | ------- | ------- | ---------------------------------------------------- |
| Tenant Portal Domain (`domain`) | Yes      | String  |         | Tenant URL without protocol.                         |
| API Token (`api_token`)         | Yes      | String  |         | Token created under API tokens.                      |
| Proxy (`proxy`)                 | No       | String  |         | Proxy host and port, sent as an `http://` proxy URL. |
| Timeout (`timeout`)             | No       | Integer | 30      | Seconds to wait for API responses.                   |

## Troubleshooting

| Error message            | Cause                                    | Fix                                                                                                |
| ------------------------ | ---------------------------------------- | -------------------------------------------------------------------------------------------------- |
| Max retries exceeded for | The API kept returning 429 (rate limit). | Wait and run the discovery again. The connector waits for the `Retry-After` time between attempts. |

## Change history
