Skip to content

Commit 40c8d3c

Browse files
committed
Add copy SPO file and tweak format/wording
1 parent 9485b33 commit 40c8d3c

File tree

3 files changed

+57
-24
lines changed

3 files changed

+57
-24
lines changed

articles/data-factory/connector-sharepoint-online-list.md

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ ms.reviewer: douglasl
99

1010
ms.service: data-factory
1111
ms.workload: data-services
12-
13-
1412
ms.topic: conceptual
1513
ms.date: 05/19/2020
1614
ms.author: jingwang
@@ -25,42 +23,47 @@ This article outlines how to use Copy Activity in Azure Data Factory to copy dat
2523

2624
This SharePoint Online List connector is supported for the following activities:
2725

26+
- [Copy activity](copy-activity-overview.md) with [supported source/sink matrix](copy-activity-overview.md)
2827
- [Lookup activity](control-flow-lookup-activity.md)
2928

3029
You can copy data from SharePoint Online List to any supported sink data store. For a list of data stores that Copy Activity supports as sources and sinks, see [Supported data stores and formats](copy-activity-overview.md#supported-data-stores-and-formats).
3130

3231
Specifically, this SharePoint List Online connector uses service principal authentication and retrieves data via OData protocol.
3332

33+
> [!TIP]
34+
> This connector supports copying data from SharePoint Online **List** but not file. Learn how to copy file from [Copy file from SharePoint Online](#copy-file-from-sharepoint-online) section.
35+
3436
## Prerequisites
3537

3638
The SharePoint List Online connector uses service principal authentication to connect to SharePoint. Follow these steps to set it up:
3739

3840
1. Register an application entity in Azure Active Directory (Azure AD) by following [Register your application with an Azure AD tenant](../storage/common/storage-auth-aad-app.md#register-your-application-with-an-azure-ad-tenant). Make note of the following values, which you use to define the linked service:
3941

40-
- Application ID
41-
- Application key
42-
- Tenant ID
42+
- Application ID
43+
- Application key
44+
- Tenant ID
4345

4446
2. Grant SharePoint Online site permission to your registered application:
4547

46-
> [!NOTE]
47-
>
48-
> This operation requires SharePoint Online site owner permission. You can find the owner by going to the site home page -> click the "X members" in the right corner -> check who has the "Owner" role.
48+
> [!NOTE]
49+
> This operation requires SharePoint Online site owner permission. You can find the owner by going to the site home page -> click the "X members" in the right corner -> check who has the "Owner" role.
50+
51+
1. Open SharePoint Online site link e.g. `https://[your_site_url]/_layouts/15/appinv.aspx` (replace tenant and site name).
52+
2. Search the application ID you registered, fill the empty fields, and click "Create".
4953

50-
1. 1. Open SharePoint site link e.g. `https://[tenant-name].sharepoint.com/sites/[site-name]/_layouts/15/appinv.aspx` (replace tenant and site name).
51-
2. Search the application ID you just registered in Step 1, fill the empty fields, and click "Create".
52-
1. App Domain: localhost.com
53-
2. Redirect URL: https://www.localhost.com
54-
3. Permission Request XML:
55-
3. ```xml
56-
<AppPermissionRequests AllowAppOnlyPolicy="true">
57-
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Read"/>
58-
</AppPermissionRequests>
59-
```
54+
- App Domain: localhost.com
55+
- Redirect URL: https://www.localhost.com
56+
- Permission Request XML:
6057

61-
2. ![sharepoint grant permission](media/connector-sharepoint-online-list/sharepoint-online-grant-permission.png)
58+
```xml
59+
<AppPermissionRequests AllowAppOnlyPolicy="true">
60+
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Read"/>
61+
</AppPermissionRequests>
62+
```
6263

63-
3. 3. Click "Trust It" for this app.
64+
![sharepoint grant permission](media/connector-sharepoint-online-list/sharepoint-online-grant-permission.png)
65+
66+
3. Click "Trust It" for this app.
6467

6568
## Get started
6669

@@ -75,7 +78,7 @@ The following properties are supported for an SharePoint Online List linked serv
7578
| **Property** | **Description** | **Required** |
7679
| ------------------- | ------------------------------------------------------------ | ------------ |
7780
| type | The type property must be set to: **SharePointOnlineList**. | Yes |
78-
| siteUrl | The SharePoint Online site url. Eg. `https://[tenant-name].sharepoint.com/sites/[site-name]`. | Yes |
81+
| siteUrl | The SharePoint Online site url, e.g. `https://contoso.sharepoint.com/sites/siteName`. | Yes |
7982
| servicePrincipalId | The Application (client) ID of the application registered in Azure Active Directory. | Yes |
8083
| servicePrincipalKey | The application's key. Mark this field as a **SecureString** to store it securely in Data Factory, or [reference a secret stored in Azure Key Vault](store-credentials-in-key-vault.md). | Yes |
8184
| tenantId | The tenant ID under which your application resides. | Yes |
@@ -89,13 +92,13 @@ The following properties are supported for an SharePoint Online List linked serv
8992
"properties": {
9093
"type": "SharePointOnlineList",
9194
"typeProperties": {
92-
"siteUrl": "https://[tenant-name].sharepoint.com/sites/[site-name]",
95+
"siteUrl": "<site URL>",
9396
"servicePrincipalId": "<service principal id>",
9497
"servicePrincipalKey": {
9598
"type": "SecureString",
9699
"value": "<service principal key>"
97100
},
98-
"tenantId": "<tenant GUID>"
101+
"tenantId": "<tenant ID>"
99102
}
100103
}
101104
}
@@ -124,7 +127,7 @@ For a full list of sections and properties that are available for defining datas
124127
},
125128
"typeProperties":
126129
{
127-
"listName": "MyList"
130+
"listName": "<name of the list>"
128131
}
129132
}
130133
}
@@ -198,6 +201,36 @@ When you copy data from SharePoint Online List, the following mappings are used
198201
| External Data | Not supported | |
199202
| Managed Metadata | Not supported | |
200203

204+
## Copy file from SharePoint Online
205+
206+
You can copy file from SharePoint Online by using **Web activity** to authenticate and grab access token from SPO, then passing to subsequent **Copy activity** to copy data with **HTTP connector as source**.
207+
208+
![sharepoint copy file flow](media/connector-sharepoint-online-list/sharepoint-online-copy-file-flow.png)
209+
210+
1. Follow the [Prerequisites](#prerequisites) section to create AAD application and grant permission to SharePoint Online.
211+
212+
2. Create a **Web Activity** to get the access token from SharePoint Online:
213+
214+
- **URL**: `https://accounts.accesscontrol.windows.net/[Tenant-ID]/tokens/OAuth/2`. Replace the tenant ID.
215+
- **Method**: POST
216+
- **Headers**:
217+
- Content-Type: application/x-www-form-urlencoded
218+
- **Body**: `grant_type=client_credentials&client_id=[Client-ID]@[Tenant-ID]&client_secret=[Client-Secret]&resource=00000003-0000-0ff1-ce00-000000000000/[Tenant-Name].sharepoint.com@[Tenant-ID]`. Replace the client ID, client secret, tenant ID and and tenant name.
219+
220+
> [!CAUTION]
221+
> Set the Secure Output option to true in Web activity to prevent the token value from being logged in plain text. Any further activities that consume this value should have their Secure Input option set to true.
222+
223+
3. Chain with a **Copy activity** with HTTP connector as source to copy SharePoint Online file content:
224+
225+
- HTTP linked service:
226+
- **Base URL**: `https://[site-url]/_api/web/GetFileByServerRelativeUrl('[relative-path-to-file]')/$value`. Replace the site URL and relative path to file. Sample relative path to file as `/sites/site2/Shared Documents/TestBook.xlsx`.
227+
- **Authentication type:** Anonymous *(to use the Bearer token configured in copy activity source later)*
228+
- Dataset: choose the format you want. To copy file as-is, select "Binary" type.
229+
- Copy activity source:
230+
- **Request method**: GET
231+
- **Additional header**: use the following expression`@{concat('Authorization: Bearer ', activity('<Web-activity-name>').output.access_token)}`, which uses the Bearer token generated by the upstream Web activity as authorization header. Replace the Web activity name.
232+
- Configure the copy activity sink as usual.
233+
201234
## Lookup activity properties
202235

203236
To learn details about the properties, check [Lookup activity](control-flow-lookup-activity.md).
4.79 KB
Loading
4.22 KB
Loading

0 commit comments

Comments
 (0)