docs/Microsoft-365-Copilot-Setup.md
This guide walks you through setting up and using Microsoft 365 Copilot with Fabric CLI. Microsoft 365 Copilot provides AI capabilities grounded in your organization's Microsoft 365 data, including emails, documents, meetings, and more.
NOTE: As per the conversation in discussion 1853 - enterprise users with restrictive consent policies will probably need their IT admin to either create an app registration with the required permissions, or grant admin consent for an existing app like Graph Explorer.
Microsoft 365 Copilot is an AI-powered assistant that works across Microsoft 365 applications. When integrated with Fabric, it allows you to:
Before you begin, ensure you have:
The following Microsoft Graph permissions are needed:
| Permission | Type | Description |
|---|---|---|
Sites.Read.All | Delegated | Read SharePoint sites |
Mail.Read | Delegated | Read user's email |
People.Read.All | Delegated | Read organization's people directory |
OnlineMeetingTranscript.Read.All | Delegated | Read meeting transcripts |
Chat.Read | Delegated | Read Teams chat messages |
ChannelMessage.Read.All | Delegated | Read Teams channel messages |
ExternalItem.Read.All | Delegated | Read external content connectors |
Fabric CLI - Copilothttp://localhost:8400/callbackAfter registration, note these values from the Overview page:
12345678-1234-1234-1234-123456789abcabcdef12-3456-7890-abcd-ef1234567890Sites.Read.AllMail.ReadPeople.Read.AllOnlineMeetingTranscript.Read.AllChat.ReadChannelMessage.Read.AllExternalItem.Read.Alloffline_access (for refresh tokens)If you want to use client credentials for token refresh:
The Microsoft 365 Copilot Chat API requires delegated permissions, meaning you need to authenticate as a user. There are several ways to obtain tokens:
# Install Azure CLI if not already installed
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
# Login with your work account
az login --tenant YOUR_TENANT_ID
# Get an access token for Microsoft Graph
az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv
For headless environments or when browser authentication isn't possible:
# Request device code
curl -X POST "https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/devicecode" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=YOUR_CLIENT_ID&scope=Sites.Read.All Mail.Read People.Read.All OnlineMeetingTranscript.Read.All Chat.Read ChannelMessage.Read.All ExternalItem.Read.All offline_access"
# Follow the instructions to authenticate in a browser
# Then poll for the token using the device_code from the response
For production applications, use Microsoft Authentication Library (MSAL):
// Example using Azure Identity SDK for Go
import "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
cred, err := azidentity.NewInteractiveBrowserCredential(&azidentity.InteractiveBrowserCredentialOptions{
TenantID: "YOUR_TENANT_ID",
ClientID: "YOUR_CLIENT_ID",
})
Run Fabric Setup:
fabric --setup
Select Copilot from the menu:
Copilot in the numbered listEnter Configuration Values:
[Copilot] Enter your Azure AD Tenant ID:
> contoso.onmicrosoft.com
[Copilot] Enter your Azure AD Application (Client) ID:
> 12345678-1234-1234-1234-123456789abc
[Copilot] Enter your Azure AD Client Secret (optional):
> (press Enter to skip, or enter secret for token refresh)
[Copilot] Enter a pre-obtained OAuth2 Access Token:
> eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIs...
[Copilot] Enter a pre-obtained OAuth2 Refresh Token (optional):
> (press Enter to skip, or enter refresh token)
[Copilot] Enter your timezone:
> America/New_York
Edit ~/.config/fabric/.env:
# Microsoft 365 Copilot Configuration
COPILOT_TENANT_ID=contoso.onmicrosoft.com
COPILOT_CLIENT_ID=12345678-1234-1234-1234-123456789abc
COPILOT_CLIENT_SECRET=your-client-secret-if-applicable
COPILOT_ACCESS_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIs...
COPILOT_REFRESH_TOKEN=your-refresh-token-if-available
COPILOT_API_BASE_URL=https://graph.microsoft.com/beta/copilot
COPILOT_TIME_ZONE=America/New_York
fabric --listmodels | grep -i copilot
Expected output:
[X] Copilot|microsoft-365-copilot
# Simple query
echo "What meetings do I have tomorrow?" | fabric --vendor Copilot
# With explicit model (though there's only one)
echo "Summarize my recent emails" | fabric --vendor Copilot --model microsoft-365-copilot
echo "What are the key points from my last team meeting?" | \
fabric --vendor Copilot --stream
# Use a pattern with Copilot
echo "Find action items from my recent emails" | \
fabric --pattern extract_wisdom --vendor Copilot
echo "What meetings do I have scheduled for next week?" | fabric --vendor Copilot
echo "Summarize the emails I received yesterday from my manager" | fabric --vendor Copilot
echo "Find documents about the Q4 budget proposal" | fabric --vendor Copilot
echo "What were the main discussion points in the engineering standup channel this week?" | fabric --vendor Copilot
echo "What action items came out of the project review meeting on Monday?" | fabric --vendor Copilot
# Extract wisdom from organizational content
echo "What are the key decisions from last month's leadership updates?" | \
fabric --pattern extract_wisdom --vendor Copilot
# Summarize with a specific pattern
echo "Summarize the HR policy document about remote work" | \
fabric --pattern summarize --vendor Copilot
Cause: Invalid or expired access token
Solutions:
Obtain a fresh access token:
az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv
Update your configuration:
fabric --setup
# Select Copilot and enter the new token
Check token hasn't expired (tokens typically expire after 1 hour)
Cause: Missing permissions or admin consent not granted
Solutions:
Cause: API access issues or service unavailable
Solutions:
https://graph.microsoft.com/beta/copilotCause: Too many requests
Solutions:
Cause: Missing client secret or refresh token
Solutions:
/beta endpoint) and subject to changeThe Microsoft Graph API has rate limits that apply:
Consult Microsoft Graph throttling guidance for details.
Copilot indexes data from Microsoft 365 services. There may be a delay between when content is created and when it becomes available in Copilot responses.
Microsoft 365 Copilot integration with Fabric provides enterprise-ready AI capabilities grounded in your organization's data. Key points:
microsoft-365-copilot)# 1. Set up Azure AD app registration (see guide above)
# 2. Get access token
az login --tenant YOUR_TENANT_ID
ACCESS_TOKEN=$(az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv)
# 3. Configure Fabric
fabric --setup
# Select Copilot, enter tenant ID, client ID, and access token
# 4. Test it
echo "What meetings do I have this week?" | fabric --vendor Copilot
Happy prompting with Microsoft 365 Copilot!