This page describes how to create a data store and connect Microsoft OneDrive to Gemini Enterprise.

## Before you begin

> [!NOTE]
> **Note:** To enforce data source access control and secure data in Gemini Enterprise, ensure that you have [configured your identity provider](https://docs.cloud.google.com/gemini/enterprise/docs/configure-identity-provider.md.txt).

Ensure the following before you set up your Microsoft OneDrive connection.

1.
   Grant the Discovery Engine Editor role (`roles/discoveryengine.editor`). This role is required for the user to create the data store. To grant this role, do the following:

   1. In the Google Cloud console, go to the **IAM** page.

      [Go to IAM](https://console.cloud.google.com/iam-admin/iam)
   2. Locate the user account and click edit **Edit**.
   3. Grant the `Discovery Engine Editor` role to the user. For more information, see [IAM roles and permissions](https://cloud.google.com/gemini/enterprise/docs/access-control).

   <br />

2. Register Gemini Enterprise as an
   [OAuth 2.0 application in Microsoft Entra ID](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/third-party-config.md.txt)
   and [obtain the following credentials](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/third-party-config.md.txt#obtain-client-id-and-client-secret):

   - Client ID

   - Client secret

   - Tenant ID

3. Configure the [Microsoft API application permissions](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/third-party-config.md.txt#microsoft-graph-minimum-permissions)
   with the consent of a Microsoft OneDrive administrator.

## Create Microsoft OneDrive data store

To create a Microsoft OneDrive data store, perform the following steps:

1. In the Google Cloud console, go to the Gemini Enterprise page.

   [Gemini Enterprise](https://console.cloud.google.com/gemini-enterprise/)
2. Select or [create](https://cloud.google.com/resource-manager/docs/creating-managing-projects) a Google Cloud project.

3. In the navigation menu, click **Data stores**.

4. Click **Create data store**.

5. In the **Source** section, search for **Microsoft OneDrive** , and click **Select**.

6. In the **Data** section:

   1. In the **Connector mode** section, select **Data ingestion** or **Federated search** as the connection mode.
   2. Click **Continue**.

   3. In the **Authentication settings** section, configure authentication based on your chosen connection mode.

      1. Provide the following authentication details:
         - **Client ID:** The unique identifier of the application registered in your organization's Microsoft Entra ID.
         - **Client secret:** The secret key generated during the OAuth 2.0 application registration process in Microsoft Entra ID.
         - **Tenant ID:** The unique identifier for your organization in Microsoft Entra admin center.
           For more information, see [Obtain client credentials](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/third-party-config.md.txt#obtain-client-id-and-client-secret).

         - **Microsoft OneDrive Environment Type:** Select the environment that hosts your Microsoft 365 tenant:

           - Select **Standard** (the default) if you connect to standard commercial Microsoft 365 or Government Community Cloud (GCC).
           - Select **US Government** if you connect to a Microsoft 365 US Government sovereign cloud (GCC High or DoD).

         > [!NOTE]
         > **Note:** These settings apply only to Microsoft 365 US Government (sovereign cloud) customers. If you connect to a US Government cloud, use the matching combination; otherwise keep the defaults (**Standard** and **Global** ):
         > - **GCC** : Environment Type **Standard** , Cloud Environment **GCC**.
         > - **GCC High** : Environment Type **US Government** , Cloud Environment **GCC High**.
         > - **DoD** : Environment Type **US Government** , Cloud Environment **DoD**.

      - If you selected **Data ingestion** with **Federated credentials** authentication method, copy the **Subject identifier** and use it to [add federated credential for data ingestion](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/third-party-config.md.txt#add-fed-credentials).

        - **Subject identifier:** The unique ID of the service account you plan to use.
      - If you selected **Federated search** , click **Login** and complete the Microsoft sign-in.

   4. Click **Continue**.

   5. If you selected **Federated search**, do the following:

      1. In the **Destinations** section, enter the base URL for your Microsoft OneDrive site.

      2. In the **Advanced options** section,

         1. Select your **Microsoft 365 Cloud Environment** :
            - If you connect to a Microsoft 365 US Government instance, select the option that matches it: **GCC** , **GCC High** , or **DoD**.
            - Otherwise, keep the default, **Global**.
         2. Enter **Azure Tenant**, the tenant ID that you obtained when you created the Entra application.
         3. You can refine the scope of your searches and actions by specifying which Microsoft OneDrive paths to include or exclude. You can only mutate or retrieve data within the included paths. Requests for out-of-scope data either fail or return no results.

            You can add filters to the data store using the Google Cloud console or API:

            ### Console

            Note: When entering multiple sites, separate each URL with a comma. You can also copy and paste a list of URLs directly from a CSV file.
            1. In the Path filter section:
               - Choose the filter type: **Include in search** or **Exclude from search**.
               - In the **Path filter** field, enter the full OneDrive paths.

                 **Note:** This field supports subpaths, folders, and document libraries, in the format, `https://{your-tenant}.sharepoint.com/sites/{your-site-name}/{your-folder-name}/`. Any content under the specified path will be filtered.

            ### REST

            To add filters when creating a data store, call the [`setUpDataConnector`](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1alpha/projects.locations/setUpDataConnector.md.txt) method.

            ```sh
            curl -X POST \
                    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
                    -H "Content-Type: application/json" \
                    -H "X-Goog-User-Project: PROJECT_ID" \
                    "https://ENDPOINT_LOCATION-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION:setUpDataConnector" \
                    -d '{
                    "collectionId": "COLLECTION_ID",
                    "collectionDisplayName": "COLLECTION_DISPLAY_NAME",
                    "dataConnector": {
                        "dataSource": "sharepoint_federated_search",
                        "params": {
                        "client_id": "CLIENT_ID",
                        "client_secret": "CLIENT_SECRET",
                        "instance_uri": "INSTANCE_URI",
                        "tenant_id": "TENANT_ID",
                        "FILTER_TYPE": {
                            "FILTER_KEY": [
                            "FILTER_VALUE1",
                            "FILTER_VALUE2"
                            ]
                        }
                        },
                        "entities": [
                        {
                            "entityName": "file"
                        }
                        ],
                        "refreshInterval": "7200s",
                        "connectorType": "THIRD_PARTY_FEDERATED",
                        "connectorModes": [
                        "FEDERATED"
                        ]
                    }
                    }'
                    
            ```

            Replace the following:
            - `PROJECT_ID`: the ID of your project.
            - `ENDPOINT_LOCATION`: the multi-region for your API request. Specify one of the following values:
              - `us` for the US multi-region
              - `eu` for the EU multi-region
              - `global` for the Global location

              For more information, see [Specify a multi-region
              for your data store](https://docs.cloud.google.com/gemini/enterprise/docs/locations#specify_a_multi-region_for_your_data_store).
            - `LOCATION`: the multi-region of your data store: `global`, `us`, or `eu`
            - `COLLECTION_ID`: the unique ID of the data store.
            - `COLLECTION_DISPLAY_NAME`: the display name of the data store.
            - `CLIENT_ID`: the client ID for Microsoft OneDrive authentication.
            - `CLIENT_SECRET`: the client secret for Microsoft OneDrive authentication.
            - `INSTANCE_URI`: the instance URI for Microsoft OneDrive.
            - `TENANT_ID`: the tenant ID for Microsoft OneDrive.
            - `FILTER_TYPE`: the type of filter added to your Microsoft OneDrive data stores. For more information, see [Filter types](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/add-filters-to-onedrive-data-store.md.txt#filter-types).
            - `FILTER_KEY`: the key for the filter, corresponding to a field in your data. For more information, see [Filter keys](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/add-filters-to-onedrive-data-store.md.txt#filter-keys).
            - `FILTER_VALUES`: the value or values to filter on for the specified `FILTER_KEY`.

         For more details on filter types and adding filters, see [Add filters to Microsoft OneDrive data store](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/add-filters-to-onedrive-data-store.md.txt).
   6. If you selected **Data ingestion** , in the **Advanced options** section, do the following:

      1. Optional: To allow a set of static IP addresses in your system, select the **Enable Static IP Addresses** checkbox. For more information, see [Configure static IP egress](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/configure-static-ip-egress.md.txt).
      2. Optional: In the **Max QPS** field, enter the maximum queries per second to apply a rate limit on the queries that the connector sends to the Microsoft OneDrive instance.
      3. Optional: To attempt to decrypt all files encrypted with [Microsoft Purview](https://learn.microsoft.com/en-us/purview/purview) information protection, select **Decrypt files encrypted with *Microsoft Purview* information protection** checkbox.
   7. Click **Continue**.

   8. In the **Entities to search** (if you selected **Federated search** ) or **Entities to sync** (if you selected **Data ingestion**) section:

      1. Select all the required entities.
      2. If you selected **Federated search**, proceed to the next step.
      3. If you selected **Data ingestion** , continue with the following steps:
         1. Optional: To sync specific projects, do the following:
            1. Click **Filter**.
            2. To filter entities out of the index, select the **Exclude from the index** checkbox, or to ensure that they are included in the index, select the **Include to the index** checkbox.
            3. Enter the keys. Press enter after each key.
            4. Click **Save**.
         2. To configure the sync schedule, do the following:
            1. In the **Sync frequency** list, select the sync frequency.
               - To schedule separate full syncs of entity and identity data, expand the menu in the **Full sync** section and then select **Custom options**.
            2. In the **Incremental sync frequency** list, select the incremental sync frequency. For more information, see [Sync schedules](https://cloud.google.com/gemini/enterprise/docs/introduction-to-connectors-and-data-stores#sync-schedules).
7. Click **Continue**.

8. In the **Actions** section:

   1. If you selected **Federated search** :
      1. From **Select Microsoft OneDrive actions to enable**, select the actions from the category to enable them for the connector.
   2. If you selected **Data ingestion**:

      1. In the **Authentication settings** section, configure authentication based on your chosen connection mode.
         Provide the following authentication details:

         - **Client ID:** The unique identifier of the application registered in your organization's Microsoft Entra ID.
         - **Client Secret:** The secret key generated during the OAuth 2.0 application registration process in Microsoft Entra ID.
         - **Tenant ID:** The unique identifier for your organization in Microsoft Entra admin center.

         For more information, see [Obtain client credentials](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/ms-onedrive/third-party-config.md.txt#obtain-client-id-and-client-secret).
      2. Click **Login** and sign-in to Microsoft OneDrive to verify your account.

      3. Click **Continue**.

      4. In the **Advanced settings** section, enter **Azure Tenant**, the tenant ID that you obtained when you created the Entra application.

      5. In the **Destinations** section, enter the base URL for your Microsoft OneDrive site.

      6. From **Select Microsoft OneDrive actions to enable**, select the actions from the category to enable them for the connector.

9. Click **Continue**.

   > [!NOTE]
   > **Note:** If you skip adding actions in this step, you can add them later. For more information, see [Add actions](https://docs.cloud.google.com/gemini/enterprise/docs/manage-actions#add-actions).

   To view and manage the list of actions, see [View and manage actions](https://docs.cloud.google.com/gemini/enterprise/docs/manage-actions).
10.
    In the **Configuration** section:

    1. From the **Multi-region** list, select the location for your data connector.
    2. In the **Your data connector name** field, enter a name for your connector.
    3. If you selected `us` or `eu` as the location, configure the **Encryption settings** :
       - Optional: If you haven't configured single-region keys, click **Go to settings page** to do so. For more information, see [Register a single-region key for third-party connectors](https://docs.cloud.google.com/gemini/enterprise/docs/cmek.md.txt#third-party-connectors-key-registration).
       - Select **Google-managed encryption key** or **Cloud KMS key**.
       - If you selected **Cloud KMS key** :
         - In the **Key management type** list, select the appropriate type.
         - In the **Cloud KMS key** list, select the key.

       For more information, see [Customer-managed encryption keys](https://docs.cloud.google.com/gemini/enterprise/docs/cmek.md.txt).

    <br />

11. Click **Continue**.

12.
    In the **Billing** section, select **General pricing** or **Configurable pricing** . For more information, see [Verify the billing status of your projects](https://cloud.google.com/billing/docs/how-to/verify-billing-enabled) and [Licenses](https://docs.cloud.google.com/gemini/enterprise/docs/licenses.md.txt).

13. Click **Create** . Gemini Enterprise creates your data store and displays your data stores on the **Data Stores** page.

On the **Data Stores** page, click your data store name to see the status. After the data store state changes from **Creating** to **Active**, the Microsoft OneDrive connector is ready to be used.

For an ingestion connector created with Microsoft OneDrive, the data store state transitions from **Creating** to **Running** upon synchronization initiation. It then changes to **Active** once ingestion is complete, signifying that the data store is fully configured. Depending on data volume, ingestion may require several hours.

After creating the data store, [create an app](https://docs.cloud.google.com/gemini/enterprise/docs/create-app.md.txt), [connect it to the Microsoft OneDrive data store](https://docs.cloud.google.com/gemini/enterprise/docs/connect-existing-data-store), and [authorize](https://docs.cloud.google.com/gemini/enterprise/docs/create-app.md.txt#user-authorization) Gemini Enterprise to access Microsoft OneDrive before executing any queries.

## Enable real-time sync for data ingestion

> [!WARNING]
>
> **Preview
> --- Real-time sync**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

> [!NOTE]
> **Note:** Real-time sync is only available for the **Data ingestion** connection mode.

To enable real-time sync for your data store, follow these steps.

1. In the Google Cloud console, go to the **Gemini Enterprise** page.

   [Gemini Enterprise](https://console.cloud.google.com/gemini-enterprise/)
2. In the navigation menu, click **Data Stores**.

3. Click the name of the Microsoft OneDrive data store for which you want to
   enable real-time sync.

4. On the data store **Data** page, wait until the **Connector state** changes
   to **Active**.

5. In the **Real-time sync** field, click **View/edit**.

6. To enable real-time sync, click the **Enable real-time sync** toggle.

7. In the **Client secret** field, enter a value. This value is used to verify
   Microsoft OneDrive webhook events. We recommend using a string of 20 characters.

8. Click **Save**.

   Wait for the **Real-time sync** field to change to **Running**.


## Data handling and query execution

This section describes how Gemini Enterprise manages your query and the privacy implications of using the federated data store.

### Query execution

After you authorize Microsoft OneDrive and send a search query to Gemini Enterprise:

- Gemini Enterprise sends your search query directly to the Microsoft API.
- Gemini Enterprise blends the results with those from other connected data sources and displays a comprehensive search result.

### Data handling

When using third-party federated search, the following data handling rules apply:

- Your query string is sent to the third-party search backend (Microsoft API).
- These third parties may associate queries with your identity.
- If multiple federated search data sources are enabled, the query might be sent to all of them.
- After the data reaches the third-party system, it is governed by that system's terms of service and privacy policies.

> [!NOTE]
> **Note:** To improve accuracy, an LLM may rewrite your query before it is sent to Microsoft OneDrive. This rewritten query can incorporate information from your session's query history. As a result, parts of your query history might also be included in the query sent to the Microsoft API.

<br />

## What's next

- To provide a user interface for querying your Microsoft OneDrive data, [create an app](https://docs.cloud.google.com/gemini/enterprise/docs/create-app.md.txt) and [connect it to the Microsoft OneDrive data store](https://docs.cloud.google.com/gemini/enterprise/docs/connect-existing-data-store).
- To view and manage the list of actions, see [View and manage actions](https://docs.cloud.google.com/gemini/enterprise/docs/manage-actions).
- To preview how your search results appear after your app is set up, see [Get search results](https://docs.cloud.google.com/gemini/enterprise/docs/preview-search-results.md.txt).
- To enable alerts for the data store, see [Configure alerts for third-party data stores](https://docs.cloud.google.com/gemini/enterprise/docs/configure-periodic-data-alerts).