---
title: Ingest data from Microsoft 365
description: Create and schedule a managed Microsoft 365 Unified Audit Logs ingestion pipeline using Databricks Lakeflow Connect.
canonical_url: https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-pipeline
---

# Ingest data from Microsoft 365

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md). To use it, a workspace admin must turn on **Lakeflow Connect for Microsoft 365 Unified Audit Logs** from the **Previews** page. See [Manage Databricks previews](https://docs.databricks.com/gcp/en/admin/workspace-settings/manage-previews.md).

Use Declarative Automation Bundles or a Databricks notebook to create a managed Microsoft 365 Unified Audit Logs pipeline for any of the five supported audit log source tables.

## <a id="requirements" />Requirements

* To create an ingestion pipeline, first meet the following requirements:

  * Your workspace must be enabled for Unity Catalog.

  * Serverless compute must be enabled for your workspace. See [Serverless compute requirements](https://docs.databricks.com/gcp/en/compute/serverless/index.md#requirements).

  * To create a new connection, you must have `CREATE CONNECTION` privileges on the metastore. See [Manage privileges in Unity Catalog](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/manage-privileges/index.md).

    If the connector supports UI-based pipeline authoring, an admin can create the connection and the pipeline at the same time by completing the steps on this page. However, if the users who create pipelines use API-based pipeline authoring or are non-admin users, an admin must first create the connection in Catalog Explorer. See [Connect to managed ingestion sources](https://docs.databricks.com/gcp/en/connect/managed-ingestion.md).

  * To use an existing connection, you must have `USE CONNECTION` privileges or `ALL PRIVILEGES` on the connection object.

  * You must have `USE CATALOG` privileges on the target catalog.

  * You must have `USE SCHEMA` and `CREATE TABLE` privileges on an existing schema or `CREATE SCHEMA` privileges on the target catalog.

* Configure authentication from Databricks and create a connection. See [Configure authentication to Microsoft 365](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-source-setup.md) and [Create a Microsoft 365 Unified Audit Logs connection](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-connection.md).

* Choose the source objects to ingest. For the supported objects, see [Supported source tables](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-reference.md#supported-tables).

## <a id="connector-options" />Connector options

The Microsoft 365 Unified Audit Logs connector doesn't define connector-specific pipeline options. For connection settings, see [Connection options](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-reference.md#connection-options).

## <a id="create-an-ingestion-pipeline" />Create an ingestion pipeline

Create the pipeline with Declarative Automation Bundles or a Databricks notebook.

### Declarative Automation Bundles

Use Declarative Automation Bundles to manage Microsoft 365 Unified Audit Logs pipelines as code. Bundles can contain YAML definitions of pipelines and jobs, are managed using the Databricks CLI, and can be shared across development, staging, and production workspaces. For more information, see [What are Declarative Automation Bundles?](https://docs.databricks.com/gcp/en/dev-tools/bundles/index.md).

1. Create a bundle using the Databricks CLI:

   ```bash
   databricks bundle init
   ```

2. Add a pipeline definition file, such as `resources/microsoft_365_pipeline.yml`. See [pipeline.ingestion\_definition](https://docs.databricks.com/gcp/en/dev-tools/bundles/resources.md#pipeline-ingestion_definition) and [Examples](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-pipeline.md#examples).

3. Add a job definition file, such as `resources/microsoft_365_job.yml`, to run the pipeline more frequently than every seven days.

4. Deploy the pipeline using the Databricks CLI:

   ```bash
   databricks bundle deploy
   ```

### Databricks notebook

1. Import the following notebook into your Databricks workspace:

   [Get notebook](https://docs.databricks.com/notebooks/source/saas-cdc/microsoft-365-pipeline.html)

2. Don't edit the setup cells. Edit only the last cell, which creates the pipeline. See [pipeline.ingestion\_definition](https://docs.databricks.com/gcp/en/dev-tools/bundles/resources.md#pipeline-ingestion_definition) and [Examples](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-pipeline.md#examples).

3. Optionally configure advanced pipeline settings. See [Common patterns for managed ingestion pipelines](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/common-patterns.md).

4. Click **Run all**.

## <a id="examples" />Examples

The Microsoft 365 Unified Audit Logs connector makes five source tables available in the `default` source schema. The following examples ingest Entra ID, Exchange, SharePoint, general, and data loss prevention audit events.

### Declarative Automation Bundles

The following pipeline definition file ingests all five source tables:

```yaml
resources:
  pipelines:
    microsoft_365_pipeline:
      name: microsoft_365_pipeline
      catalog: 'main'
      target: 'microsoft_365_data'
      ingestion_definition:
        connection_name: microsoft_365_connection
        objects:
          - table:
              source_schema: 'default'
              source_table: 'audit_azure_active_directory'
              destination_catalog: 'main'
              destination_schema: 'microsoft_365_data'
              destination_table: 'audit_azure_active_directory'
          - table:
              source_schema: 'default'
              source_table: 'audit_exchange'
              destination_catalog: 'main'
              destination_schema: 'microsoft_365_data'
              destination_table: 'audit_exchange'
          - table:
              source_schema: 'default'
              source_table: 'audit_sharepoint'
              destination_catalog: 'main'
              destination_schema: 'microsoft_365_data'
              destination_table: 'audit_sharepoint'
          - table:
              source_schema: 'default'
              source_table: 'audit_general'
              destination_catalog: 'main'
              destination_schema: 'microsoft_365_data'
              destination_table: 'audit_general'
          - table:
              source_schema: 'default'
              source_table: 'dlp_all'
              destination_catalog: 'main'
              destination_schema: 'microsoft_365_data'
              destination_table: 'dlp_all'
```

### Databricks notebook

The following pipeline specification ingests all five source tables:

```python
pipeline_name = "microsoft_365_pipeline"
connection_name = "<microsoft-365-connection>"
source_tables = [
    "audit_azure_active_directory",
    "audit_exchange",
    "audit_sharepoint",
    "audit_general",
    "dlp_all",
]

pipeline_spec = {
    "name": pipeline_name,
    "catalog": "main",
    "schema": "microsoft_365_pipeline",
    "ingestion_definition": {
        "connection_name": connection_name,
        "objects": [
            {
                "table": {
                    "source_schema": "default",
                    "source_table": source_table,
                    "destination_catalog": "main",
                    "destination_schema": "microsoft_365_data",
                    "destination_table": source_table,
                }
            }
            for source_table in source_tables
        ],
    },
}
json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
```

> [!NOTE]
>
> To ingest `dlp_all`, grant the `ActivityFeed.ReadDlp` application permission to the Microsoft Entra application. See [Configure API permissions](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-source-setup.md#configure-api-permissions).

### <a id="bundle-job-definition-file" />Declarative Automation Bundles job definition file

The following job definition runs the ingestion pipeline daily. Run the pipeline more frequently than every seven days because Microsoft makes Management Activity API content available for a limited time.

#### Declarative Automation Bundles

```yaml
resources:
  jobs:
    microsoft_365_job:
      name: microsoft_365_job
      schedule:
        quartz_cron_expression: '0 0 0 * * ?'
        timezone_id: 'UTC'
      tasks:
        - task_key: microsoft_365_ingestion
          pipeline_task:
            pipeline_id: ${resources.pipelines.microsoft_365_pipeline.id}
```

## <a id="common-patterns" />Common patterns

For advanced pipeline configurations, see [Common patterns for managed ingestion pipelines](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/common-patterns.md).

## <a id="next-steps" />Next steps

Start, schedule, and set alerts on your pipeline. See [Common pipeline maintenance tasks](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/pipeline-maintenance.md).

## <a id="additional-resources" />Additional resources

* [Microsoft 365 Unified Audit Logs connector FAQ](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-faq.md)
* [Microsoft 365 Unified Audit Logs connector limitations](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-limits.md)
* [Microsoft 365 Unified Audit Logs connector reference](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-reference.md)
* [Troubleshoot the Microsoft 365 Unified Audit Logs connector](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/microsoft-365-troubleshoot.md)
