Copy data from Microsoft 365 (Office 365) into Azure using Azure Data Factory or Synapse Analytics
APPLIES TO: Azure Data Factory Azure Synapse Analytics
Tip
Try out Data Factory in Microsoft Fabric, an all-in-one analytics solution for enterprises. Microsoft Fabric covers everything from data movement to data science, real-time analytics, business intelligence, and reporting. Learn how to start a new trial for free!
Azure Data Factory and Synapse Analytics pipelines integrate with Microsoft Graph data connect, allowing you to bring the rich organizational data in your Microsoft 365 (Office 365) tenant into Azure in a scalable way and build analytics applications and extract insights based on these valuable data assets. Integration with Privileged Access Management provides secured access control for the valuable curated data in Microsoft 365 (Office 365). Refer to this link for an overview of Microsoft Graph data connect.
This article outlines how to use the Copy Activity to copy data from Microsoft 365 (Office 365). For an introduction to copy data, read the copy activity overview.
Supported capabilities
This Microsoft 365 (Office 365) connector is supported for the following capabilities:
Supported capabilities | IR |
---|---|
Copy activity (source/-) | ① |
① Azure integration runtime ② Self-hosted integration runtime
ADF Microsoft 365 (Office 365) connector and Microsoft Graph Data Connect enables at scale ingestion of different types of datasets from Exchange Email enabled mailboxes, including address book contacts, calendar events, email messages, user information, mailbox settings, and so on. Refer here to see the complete list of datasets available.
For now, within a single copy activity you can only ingest data from Microsoft 365 (Office 365) into Azure Blob Storage, and Azure Data Lake Storage Gen2 in JSON format (type setOfObjects). When you copy to Azure Blob Storage, the output is a blob containing JSON text. If you want to load Microsoft 365 (Office 365) into other types of data stores or in other formats, you can chain the first copy activity with a subsequent activity to further load data into any of the supported ADF destination stores (refer to "supported as a sink" column in the "Supported data stores and formats" table).
Important
- The Azure subscription containing the data factory or Synapse workspace and the sink data store must be under the same Microsoft Entra tenant as Microsoft 365 (Office 365) tenant.
- Ensure the Azure Integration Runtime region used for copy activity as well as the destination is in the same region where the Microsoft 365 (Office 365) tenant users' mailbox is located. Refer here to understand how the Azure IR location is determined. Refer to table here for the list of supported Office regions and corresponding Azure regions.
- Service Principal authentication is the only authentication mechanism supported for Azure Blob Storage, Azure Data Lake Storage Gen2 as destination stores.
Note
Please use Azure integration runtime in both source and sink linked services. The self-hosted integration runtime and the managed virtual network integration runtime are not supported.
Prerequisites
To copy data from Microsoft 365 (Office 365) into Azure, you need to complete the following prerequisite steps:
- Your Microsoft 365 (Office 365) tenant admin must complete on-boarding actions as described here.
- Create and configure a Microsoft Entra web application in Microsoft Entra ID. For instructions, see Create a Microsoft Entra application.
- Make note of the following values, which you use to define the linked service for Microsoft 365 (Office 365):
- Tenant ID. For instructions, see Get tenant ID.
- Application ID and Application key. For instructions, see Get application ID and authentication key.
- Add the user identity who is making the data access request as the owner of the Microsoft Entra web application (from the Microsoft Entra web application > Settings > Owners > Add owner).
- The user identity must be in the Microsoft 365 (Office 365) organization you're getting data from and must not be a Guest user.
Approving new data access requests
If this is the first time you are requesting data for this context (a combination of which data table is being access, which destination account is the data being loaded into, and which user identity is making the data access request), you will see the copy activity status as "In Progress", and only when you click into "Details" link under Actions will you see the status as "RequestingConsent". A member of the data access approver group needs to approve the request in the Privileged Access Management before the data extraction can proceed.
Refer here on how the approver can approve the data access request.
Getting started
Tip
For a walkthrough of using Microsoft 365 (Office 365) connector, see Load data from Microsoft 365 (Office 365) article.
You can create a pipeline with the copy activity by using one of the following tools or SDKs. Select a link to go to a tutorial with step-by-step instructions to create a pipeline with a copy activity.
Create a linked service to Microsoft 365 (Office 365) using UI
Use the following steps to create a linked service to Microsoft 365 (Office 365) in the Azure portal UI.
Browse to the Manage tab in your Azure Data Factory or Synapse workspace and select Linked Services, then click New:
Search for Microsoft 365 (Office 365) and select the Microsoft 365 (Office 365) connector.
Configure the service details, test the connection, and create the new linked service.
Connector configuration details
The following sections provide details about properties that are used to define Data Factory entities specific to Microsoft 365 (Office 365) connector.
Linked service properties
The following properties are supported for Microsoft 365 (Office 365) linked service:
Property | Description | Required |
---|---|---|
type | The type property must be set to: Office365 | Yes |
office365TenantId | Azure tenant ID to which the Microsoft 365 (Office 365) account belongs. | Yes |
servicePrincipalTenantId | Specify the tenant information under which your Microsoft Entra web application resides. | Yes |
servicePrincipalId | Specify the application's client ID. | Yes |
servicePrincipalKey | Specify the application's key. Mark this field as a SecureString to store it securely. | Yes |
connectVia | The Integration Runtime to be used to connect to the data store. If not specified, it uses the default Azure Integration Runtime. | No |
Note
The difference between office365TenantId and servicePrincipalTenantId and the corresponding value to provide:
- If you are an enterprise developer developing an application against Microsoft 365 (Office 365) data for your own organization's usage, then you should supply the same tenant ID for both properties, which is your organization's Microsoft Entra tenant ID.
- If you are an ISV developer developing an application for your customers, then office365TenantId will be your customer's (application installer) Microsoft Entra tenant ID and servicePrincipalTenantId will be your company's Microsoft Entra tenant ID.
Example:
{
"name": "Office365LinkedService",
"properties": {
"type": "Office365",
"typeProperties": {
"office365TenantId": "<Microsoft 365 (Office 365) tenant id>",
"servicePrincipalTenantId": "<AAD app service principal tenant id>",
"servicePrincipalId": "<AAD app service principal id>",
"servicePrincipalKey": {
"type": "SecureString",
"value": "<AAD app service principal key>"
}
}
}
}
Dataset properties
For a full list of sections and properties available for defining datasets, see the datasets article. This section provides a list of properties supported by Microsoft 365 (Office 365) dataset.
To copy data from Microsoft 365 (Office 365), the following properties are supported:
Property | Description | Required |
---|---|---|
type | The type property of the dataset must be set to: Office365Table | Yes |
tableName | Name of the dataset to extract from Microsoft 365 (Office 365). Refer here for the list of Microsoft 365 (Office 365) datasets available for extraction. | Yes |
If you were setting dateFilterColumn
, startTime
, endTime
, and userScopeFilterUri
in dataset, it is still supported as-is, while you are suggested to use the new model in activity source going forward.
Example
{
"name": "DS_May2019_O365_Message",
"properties": {
"type": "Office365Table",
"linkedServiceName": {
"referenceName": "<Microsoft 365 (Office 365) linked service name>",
"type": "LinkedServiceReference"
},
"schema": [],
"typeProperties": {
"tableName": "BasicDataSet_v0.Event_v1"
}
}
}
Copy activity properties
For a full list of sections and properties available for defining activities, see the Pipelines article. This section provides a list of properties supported by Microsoft 365 (Office 365) source.
Microsoft 365 (Office 365) as source
To copy data from Microsoft 365 (Office 365), the following properties are supported in the copy activity source section:
Property | Description | Required |
---|---|---|
type | The type property of the copy activity source must be set to: Office365Source | Yes |
allowedGroups | Group selection predicate. Use this property to select up to 10 user groups for whom the data will be retrieved. If no groups are specified, then data will be returned for the entire organization. | No |
userScopeFilterUri | When allowedGroups property is not specified, you can use a predicate expression that is applied on the entire tenant to filter the specific rows to extract from Microsoft 365 (Office 365). The predicate format should match the query format of Microsoft Graph APIs, e.g. https://graph.microsoft.com/v1.0/users?$filter=Department eq 'Finance' . |
No |
dateFilterColumn | Name of the DateTime filter column. Use this property to limit the time range for which Microsoft 365 (Office 365) data is extracted. | Yes if dataset has one or more DateTime columns. Refer here for list of datasets that require this DateTime filter. |
startTime | Start DateTime value to filter on. | Yes if dateFilterColumn is specified |
endTime | End DateTime value to filter on. | Yes if dateFilterColumn is specified |
outputColumns | Array of the columns to copy to sink. | No |
Example:
"activities": [
{
"name": "CopyFromO365ToBlob",
"type": "Copy",
"inputs": [
{
"referenceName": "<Microsoft 365 (Office 365) input dataset name>",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "<output dataset name>",
"type": "DatasetReference"
}
],
"typeProperties": {
"source": {
"type": "Office365Source",
"dateFilterColumn": "CreatedDateTime",
"startTime": "2019-04-28T16:00:00.000Z",
"endTime": "2019-05-05T16:00:00.000Z",
"userScopeFilterUri": "https://graph.microsoft.com/v1.0/users?$filter=Department eq 'Finance'",
"outputColumns": [
{
"name": "Id"
},
{
"name": "CreatedDateTime"
},
{
"name": "LastModifiedDateTime"
},
{
"name": "ChangeKey"
},
{
"name": "Categories"
},
{
"name": "OriginalStartTimeZone"
},
{
"name": "OriginalEndTimeZone"
},
{
"name": "ResponseStatus"
},
{
"name": "iCalUId"
},
{
"name": "ReminderMinutesBeforeStart"
},
{
"name": "IsReminderOn"
},
{
"name": "HasAttachments"
},
{
"name": "Subject"
},
{
"name": "Body"
},
{
"name": "Importance"
},
{
"name": "Sensitivity"
},
{
"name": "Start"
},
{
"name": "End"
},
{
"name": "Location"
},
{
"name": "IsAllDay"
},
{
"name": "IsCancelled"
},
{
"name": "IsOrganizer"
},
{
"name": "Recurrence"
},
{
"name": "ResponseRequested"
},
{
"name": "ShowAs"
},
{
"name": "Type"
},
{
"name": "Attendees"
},
{
"name": "Organizer"
},
{
"name": "WebLink"
},
{
"name": "Attachments"
},
{
"name": "BodyPreview"
},
{
"name": "Locations"
},
{
"name": "OnlineMeetingUrl"
},
{
"name": "OriginalStart"
},
{
"name": "SeriesMasterId"
}
]
},
"sink": {
"type": "BlobSink"
}
}
}
]
Related content
For a list of data stores supported as sources and sinks by the copy activity, see supported data stores.