microsoft-graph-api-agent-tool(Python)

Loading...

Create agent tools for Microsoft Graph API

This notebook creates agent tools to fetch data using Microsoft Graph API's API.

To learn more about creating agent tools that connect to external services, see Databricks documentation (AWS | Azure).

Requirements

Before you begin, ensure you have the OAuth application created. See Microsoft documentation for more details.

Setup

Install the databricks-sdk.

Update the following parameters with information for your catalog and provide a name for a new connection.

  • uc_catalog: Specifies the catalog where the external function will be created.
  • uc_schema: Specifies the schema in the catalog where the external function will be created.
  • connection_name: Specifies the connection name.
3

4

5

Create a Unity Catalog Connection

Create a Unity Catalog Connection by providing the host URL and token for authentication. To learn more about supported authentication methods, see Databricks documentation (AWS | Azure).

Make sure to fill in the client_id, client_secret and TENANT_ID from the application.

You can also create a connection through the Catalog Explorer UI. See Databricks documentation (AWS | Azure).

7

Test the connection

Test the connection works by retrieving user data.

9

Create a Unity Catalog function

Now that you have a working connection create a Unity Catalog function that fetches the user's information.

Update the function name (currently microsoft_graph_users).

11

Call the function

13

Add the tool to an AI agent

Now that you have a Unity Catalog function, you can add it to an AI agent. See Databricks documentation (AWS | Azure).

Create a tool in agent code (optional)

As an alternative, you can also define this tool directly in agent code. To learn more about the differences, see Databricks documentation (AWS | Azure)

16

17