Skip to content

Commit b255835

Browse files
authored
OneDrive source connector: workflow run trigger (#687)
1 parent e18cbef commit b255835

File tree

3 files changed

+205
-9
lines changed

3 files changed

+205
-9
lines changed

docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@
276276
"examplecode/tools/azure-storage-events",
277277
"examplecode/tools/gcs-events",
278278
"examplecode/tools/google-drive-events",
279+
"examplecode/tools/onedrive-events",
279280
"examplecode/tools/sharepoint-events",
280281
"examplecode/tools/jq",
281282
"examplecode/tools/firecrawl",
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
title: OneDrive event triggers
3+
---
4+
5+
You can use OneDrive events, such as adding new files to—or updating existing files within—OneDrive folders, to automatically run Unstructured ETL+ workflows
6+
that rely on those folders as sources. This enables a no-touch approach to having Unstructured automatically process new and updated files in OneDrive folders as they are added or updated.
7+
8+
This example shows how to automate this process by adding two custom [Power Automate](https://www.microsoft.com/power-platform/products/power-automate) flows to your Microsoft 365 or Office 365 account. One flow runs
9+
whenever a new file is detected in the specified OneDrive folder. The other flow runs whenever an existing file is updated within that folder. These flows then call the [Unstructured Workflow Endpoint](/api-reference/workflow/overview) to automatically run the
10+
specified corresponding Unstructured ETL+ workflow within your Unstructured account.
11+
12+
<Note>
13+
This example uses custom Power Automate flows that you create and maintain.
14+
Any issues with file detection, timing, or flow invocation could be related to your custom flows,
15+
rather than with Unstructured. If you are getting unexpected or no results, be sure to check your custom
16+
flows' run histories first for any informational and error messages.
17+
</Note>
18+
19+
## Requirements
20+
21+
import GetStartedSimpleApiOnly from '/snippets/general-shared-text/get-started-simple-api-only.mdx'
22+
23+
To use this example, you will need the following:
24+
25+
- A Microsoft 365 or Office 365 Business or enterprise plan that includes SharePoint Online, OneDrive, and Power Automate.
26+
(Even if you only plan to use OneDrive, you still need a plan that includes SharePoint Online, because OneDrive is built on SharePoint technology.)
27+
[Shop for business plans](https://www.microsoft.com/microsoft-365/business/compare-all-microsoft-365-business-products).
28+
[Shop for enterprise plans](https://www.microsoft.com/microsoft-365/enterprise/microsoft365-plans-and-pricing).
29+
30+
- A Power Automate Premium license. [Learn how](https://learn.microsoft.com/power-platform/admin/power-automate-licensing/buy-licenses).
31+
32+
- An Unstructured account, and an Unstructured API key for your account, as follows:
33+
34+
<GetStartedSimpleApiOnly />
35+
36+
- The Unstructured Workflow Endpoint URL for your account, as follows:
37+
38+
1. In the Unstructured UI, click **API Keys** on the sidebar.<br/>
39+
2. Note the value of the **Unstructured Workflow Endpoint** field.
40+
41+
- A OneDrive source connector in your Unstructured account. [Learn how](/ui/sources/onedrive).
42+
- Some available [destination connector](/ui/destinations/overview) in your Unstructured account.
43+
- A workflow that uses the preceding source and destination connectors. [Learn how](/ui/workflows).
44+
45+
## Step 1: Create an app registration
46+
47+
In this step, you create an app registration in Microsoft Entra ID to access the Azure key vault that you will create in the next step.
48+
49+
1. Sign in to your [Azure portal](https://portal.azure.com).
50+
2. In the **Search resources, services, and docs** box, enter **App registrations**, and then in the list of **Services**, click **App registrations**.
51+
3. Click **+ New registration**.
52+
4. Enter some **Name** for the app registration.
53+
5. For **Supported account types**, select **Accounts in this organizational directory only**.
54+
6. For **Redirect URI**, select **Web**, and then enter `https://localhost`.
55+
7. Click **Register**.
56+
8. In the sidebar, click **Overview**.
57+
9. Expand **Essentials**, and note the values of the **Application (client) ID** and **Directory (tenant) ID** fields.
58+
10. Next to **Client credentials**, click the **Add a certificate or secret** link.
59+
11. On the **Client secrets** tab, click **+ New client secret**.
60+
12. (Optional) Enter some **Description** for the client secret.
61+
13. (Optional) Enter some non-default **Expires** value.
62+
14. Click **Add**.
63+
15. Note the value of the **Value** field. This is the app registration's client secret value. (Do not use the **Secret ID** value.)
64+
65+
## Step 2: Create an Azure key vault
66+
67+
In this step, you store your Unstructured API key in an Azure key vault for your Power Automate flow to access later.
68+
69+
1. With your Azure portal still open from the previous step, in the **Search resources, services, and docs** box, enter **Key vaults**, and then in the list of **Services**, click **Key vaults**.
70+
2. Click **Create**.
71+
3. On the **Basics** tab, set the following key vault settings:
72+
73+
| Setting | Suggested value | Description |
74+
|---|---|---|
75+
| **Subscription** | Your subscription | The Azure subscription within which to create your new key vault. |
76+
| **Resource Group** | **Create new** | After you click **Create new**, enter some name for the new resource group within which to create your new key vault. |
77+
| **Key vault name** | Some globally unique name | Some name that identifies your new key vault. Valid characters are `A`-`Z`, `a`-`z`, `0`-`9`, and `-`. |
78+
| **Region** | Your preferred region | Select a region that's near you or near other services that your key vault can access. |
79+
| **Pricing tier** | **Standard** | Choose the pricing tier for your key vault. |
80+
81+
4. Click **Review + create**.
82+
5. Click **Create**.
83+
6. After the deployment is complete, click **Go to resource**.
84+
7. In the sidebar, click **Access control (IAM)**.
85+
8. Click **+ Add > Add role assignment**.
86+
9. On the **Role** tab, in the **Job function roles** list, select **Key Vault Administrator**.
87+
10. Click **Next**.
88+
11. On the **Members** tab, with **Assign access to** set to **User, group, or service principal**, click **+ Select members**.
89+
12. Search for and select the name of the app registration that you created earlier in Step 1.
90+
13. Search also for and select your user account.
91+
14. Click **Select**.
92+
15. Click **Review + assign** twice.
93+
16. In the sidebar, expand **Objects**, and then click **Secrets**.
94+
17. Click **+ Generate/Import**.
95+
18. Enter some **Name** for the secret.
96+
19. For **Secret value**, enter your Unstructured API key value.
97+
20. Click **Create**.
98+
99+
## Step 3: Create the first Power Automate flow
100+
101+
1. Sign in to [Power Automate](https://make.powerautomate.com).
102+
2. On the sidebar, click **Create**.
103+
3. In the **Start from blank** area, click **Automated cloud flow**.
104+
4. Enter some **Flow name** for your new flow.
105+
5. For **Search all triggers**, enter `When a file is created`, and then click
106+
**When a file is created (OneDrive for Business)**.
107+
6. Click **Create**.
108+
7. In the flow designer, click the **When a file is created** node.
109+
8. When prompted, sign in to OneDrive.
110+
9. On the **Parameters** tab, set the following node properties:
111+
112+
- For **Folder**, click the folder icon, and the select the folder that matches the value of the **Path** value for the OneDrive source connector for your workflow.
113+
- For **Include subfolders**, select **Yes** only if you also checked the **Recursive** checkbox for the OneDrive source connector for your workflow.
114+
115+
10. Below the **When a file is created** node, click the plus (**Insert a new action...**) button.
116+
11. In the **Search for an action or connector** box, enter `Get secret`, and then under **Azure Key Vault**, select **Get secret**.
117+
12. Set the following node properties:
118+
119+
- Enter some **Connection name** for the connection.
120+
- For **Authentication type**, select **Service principal authentication**.
121+
- For **Client ID**, enter the **Application (client) ID** value of the app registration that you created earlier in Step 1.
122+
- For **Client secret**, enter the client secret value of the app registration that you created earlier in Step 1.
123+
- For **Tenant ID**, enter the **Directory (tenant) ID** value of the app registration that you created earlier in Step 1.
124+
- For **Key vault name**, enter the name of the key vault that you created earlier in Step 2.
125+
126+
13. Click **Create new**.
127+
14. In the **Name of the secret** list, select the name of the secret that you created earlier in Step 2.
128+
15. Below the **Get secret** node, click the plus (**Insert a new action...**) button.
129+
16. In the **Search for an action or connector** box, enter `HTTP`, and then under **HTTP**, select **HTTP**.
130+
17. On the **Parameters** tab, set the following node properties:
131+
132+
- For **URI**, enter `<unstructured-api-url>/workflows/<workflow-id>/run`, and replace the following placeholders:
133+
134+
- Replace `<unstructured-api-url>` with your Unstructured Worfklow Endpoint value.
135+
- Replace `<workflow-id>` with the ID of your Unstructured workflow.
136+
137+
The **URI** should now look similar to the following:
138+
139+
```text
140+
https://platform.unstructuredapp.io/api/v1/workflows/11111111-1111-1111-1111-111111111111/run
141+
```
142+
143+
- For **Method**, select **POST**.
144+
- For **Headers**, enter the following:
145+
146+
- `accept`, set to `application/json`
147+
- `unstructured-api-key`, set to your key vault value. To do this, type `/` and select **Insert dynamic content**.
148+
Under **Get secret**, select **body/value**.
149+
150+
18. In the top navigation bar, click the disk (**Save**) button.
151+
19. Click **Back** to go to the flow's home page.
152+
20. In the top navigation bar, if the power button shows **Turn on**, click it to change it to **Turn off** (which means that the flow is on and active).
153+
154+
## Step 4: Create the second Power Automate flow
155+
156+
1. With the flow's home page still open, on the sidebar, click **My flows**.
157+
2. In the list of flows, rest your mouse pointer on the flow that you created earlier in Step 3, and then click the ellipsis (three dots, **More commands**) icon.
158+
3. Click **Save as**.
159+
4. Give the new flow a **Flow name** that is different from the original flow's name.
160+
5. Click **Save**.
161+
6. In the list of flows, rest your mouse pointer on the flow that you just created, and then click the pencil (**Edit**) icon.
162+
7. In the flow designer, right click the **When a file is created** node, and then click **Delete**.
163+
8. Click the **Add a trigger** node.
164+
9. In the **Search for an action or connector** box, enter `When a file is modified`, and then click
165+
**When a file is modified (OneDrive for Business)**.
166+
10. On the **Parameters** tab, set the following node properties:
167+
168+
- For **Folder**, click the folder icon, and the select the folder that matches the value of the **Path** value for the OneDrive source connector for your workflow.
169+
- For **Include subfolders**, select **Yes** only if you also checked the **Recursive** checkbox for the OneDrive source connector for your workflow.
170+
171+
11. In the top navigation bar, click the disk (**Save**) button.
172+
12. Click **Back** to go to the flow's home page.
173+
13. In the top navigation bar, if the power button shows **Turn on**, click it to change it to **Turn off** (which means that the flow is on and active).
174+
175+
## Step 5: Trigger the flows and view results
176+
177+
1. On a separate tab in your web browser, go to the OneDrive folder that corresponds to both your Unstructured workflow's
178+
OneDrive source connector and the Power Automate flows' **When a file is created** and **When a file is modified** nodes.
179+
2. Add a file to the OneDrive folder.
180+
3. On a separate tab in your web browser, in the Unstructured user interface for your account, click **Jobs** on the sidebar.
181+
4. In the list of jobs, click the newly running job for your workflow. It might take a minute or so for the new job to appear in the list.
182+
5. After the job status shows **Finished**, go to your destination location to see the results.
183+
6. Repeat this step, but this time, update an existing file in the OneDrive folder.
184+
185+
## Step 6 (Optional): Turn off the flows
186+
187+
To stop the Power Automate flows from running automatically, go back to the web browser tab from earlier in Steps 3 and 4. Then, do the following:
188+
189+
1. On the sidebar, click **My flows**.
190+
2. In the list of flows, click the name of the flow that you created earlier in Step 3.
191+
3. With the flow's home page still open, in the top navigation bar, click the power (**Turn off**) button
192+
to change it to **Turn on** (which means that the flow is off and inactive).
193+
4. Repeat this step, but this time, click the name of the flow that you created earlier in Step 4.

examplecode/tools/sharepoint-events.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ In this step, you create an app registration in Microsoft Entra ID to access the
5454
7. Click **Register**.
5555
8. In the sidebar, click **Overview**.
5656
9. Expand **Essentials**, and note the values of the **Application (client) ID** and **Directory (tenant) ID** fields.
57-
10. Click **Client credentials**.
57+
10. Next to **Client credentials**, click the **Add a certificate or secret** link.
5858
11. On the **Client secrets** tab, click **+ New client secret**.
5959
12. (Optional) Enter some **Description** for the client secret.
6060
13. (Optional) Enter some non-default **Expires** value.
@@ -90,7 +90,7 @@ In this step, you store your Unstructured API key in an Azure key vault for your
9090
14. Click **Select**.
9191
15. Click **Review + assign** twice.
9292
16. In the sidebar, expand **Objects**, and then click **Secrets**.
93-
17. Click **+ Generate/import**.
93+
17. Click **+ Generate/Import**.
9494
18. Enter some **Name** for the secret.
9595
19. For **Secret value**, enter your Unstructured API key value.
9696
20. Click **Create**.
@@ -123,9 +123,10 @@ In this step, you store your Unstructured API key in an Azure key vault for your
123123
- For **Key vault name**, enter the name of the key vault that you created earlier in Step 2.
124124

125125
12. Click **Create new**.
126-
13. Below the **Get secret** node, click the plus (**Insert a new action...**) button.
127-
14. In the **Search for an action or connector** box, enter `HTTP`, and then under **HTTP**, select **HTTP**.
128-
15. On the **Parameters** tab, set the following node properties:
126+
13. In the **Name of the secret** list, select the name of the secret that you created earlier in Step 2.
127+
14. Below the **Get secret** node, click the plus (**Insert a new action...**) button.
128+
15. In the **Search for an action or connector** box, enter `HTTP`, and then under **HTTP**, select **HTTP**.
129+
16. On the **Parameters** tab, set the following node properties:
129130

130131
- For **URI**, enter `<unstructured-api-url>/workflows/<workflow-id>/run`, and replace the following placeholders:
131132

@@ -145,9 +146,9 @@ In this step, you store your Unstructured API key in an Azure key vault for your
145146
- `unstructured-api-key`, set to your key vault value. To do this, type `/` and select **Insert dynamic content**.
146147
Under **Get secret**, select **body/value**.
147148

148-
16. In the top navigation bar, click the disk (**Save**) button.
149-
17. Click **Back** to go to the flow's home page.
150-
18. In the top navigation bar, click the power (**Turn on**) button.
149+
17. In the top navigation bar, click the disk (**Save**) button.
150+
18. Click **Back** to go to the flow's home page.
151+
19. In the top navigation bar, if the power button shows **Turn on**, click it to change it to **Turn off** (which means that the flow is on and active).
151152

152153
## Step 4: Trigger the flow and view results
153154

@@ -161,4 +162,5 @@ In this step, you store your Unstructured API key in an Azure key vault for your
161162
## Step 5 (Optional): Turn off the flow
162163

163164
To stop the Power Automate flow from running automatically, go back to the web browser tab from earlier in Step 3. Then,
164-
with the flow's home page still open, in the top navigation bar, click the power (**Turn off**) button.
165+
with the flow's home page still open, in the top navigation bar, click the power (**Turn off**) button
166+
to change it to **Turn on** (which means that the flow is off and inactive).

0 commit comments

Comments
 (0)