Skip to content

Commit 20b9afa

Browse files
authored
Merge pull request #211053 from Juliako/logicapparm
logicapp with arm
2 parents cd4b837 + bd981b9 commit 20b9afa

18 files changed

+268
-3
lines changed
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
---
2+
title: Logic Apps connector with ARM-based AVI accounts
3+
description: This article shows how to unlock new experiences and monetization opportunities Azure Video Indexer connectors with Logic App and Power Automate with AVI ARM accounts.
4+
ms.author: Itnorman
5+
ms.topic: how-to
6+
ms.date: 08/04/2022
7+
---
8+
9+
# Logic Apps connector with ARM-based AVI accounts
10+
11+
Azure Video Indexer (AVI) [REST API](https://api-portal.videoindexer.ai/api-details#api=Operations&operation=Upload-Video) supports both server-to-server and client-to-server communication. The API enables you to integrate video and audio insights into your application logic. To make the integration easier, we support [Logic Apps](https://azure.microsoft.com/services/logic-apps/) and [Power Automate](https://preview.flow.microsoft.com/connectors/shared_videoindexer-v2/video-indexer-v2/) connectors that are compatible with the Azure Video Indexer API.
12+
13+
You can use the connectors to set up custom workflows to effectively index and extract insights from a large amount of video and audio files, without writing a single line of code. Furthermore, using the connectors for the integration gives you better visibility on the health of your workflow and an easy way to debug it.
14+
15+
To help you get started quickly with the Azure Video Indexer connectors, the example in this article creates Logic App flows. The Logic App and Power Automate capabilities and their editors are almost identical, thus the diagrams and explanations are applicable to both. The example in this article is based on the ARM AVI account. If you're working with a classic account, see [Logic App connectors with classic-based AVI accounts](logic-apps-connector-tutorial.md).
16+
17+
The "upload and index your video automatically" scenario covered in this article is composed of two different flows that work together. The "two flow" approach is used to support async upload and indexing of larger files effectively.
18+
19+
* The first flow is triggered when a blob is added or modified in an Azure Storage account. It uploads the new file to Azure Video Indexer with a callback URL to send a notification once the indexing operation completes.
20+
* The second flow is triggered based on the callback URL and saves the extracted insights back to a JSON file in Azure Storage.
21+
22+
> [!NOTE]
23+
> For details about the Azure Video Indexer REST ARM API and the request/response examples, see [API](https://aka.ms/avam-arm-api). For example, [Generate an Azure Video Indexer access token](/rest/api/videoindexer/generate/access-token?tabs=HTTP). Press **Try it** to get the correct values for your account.
24+
>
25+
> If you are using a classic AVI account, see [Logic Apps connector with classic-based AVI accounts]( logic-apps-connector-tutorial.md).
26+
27+
## Prerequisites
28+
29+
- [!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
30+
- Create an ARM-based [Azure Video Indexer account](create-account-portal.md).
31+
- Create an Azure Storage account. Keep note of the access key for your Storage account.
32+
33+
Create two containers: one to store the media files, second to store the insights generated by Azure Video Indexer. In this article, the containers are `videos` and `insights`.
34+
35+
## Set up the first flow - file upload
36+
37+
In this section you'll, you create the following flow. The first flow is triggered when a blob is added or modified in an Azure Storage account. It uploads the new file to Azure Video Indexer with a callback URL to send a notification once the indexing operation completes.
38+
39+
The following image shows the first flow:
40+
41+
![Screenshot of the file upload flow.](./media/logic-apps-connector-arm-accounts/first-flow-high-level.png)
42+
43+
1. Create the [Logic App](https://ms.portal.azure.com/#create/Microsoft.LogicApp). We create a Logic App in the same region as the Azure Video Indexer region (recommended but not required). We call the logic app `UploadIndexVideosApp`.
44+
45+
1. Select **Consumption** for **Plan type**.
46+
1. Press **Review + Create** -> **Create**.
47+
1. Once the Logic App deployment is complete, in the Azure portal, go to the newly created Logic App.
48+
1. Under the **Settings** section, on the left side's panel, select the **Identity** tab.
49+
1. Under **System assigned**, change the **Status** from **Off** to **On** (the step is important for later on in this tutorial).
50+
1. Press **Save** (on the top of the page).
51+
1. Select the **Logic app designer** tab, in the pane on the left.
52+
1. Pick a **Blank Logic App** flow.
53+
1. Search for "blob".
54+
1. In the **All** tab, choose the **Azure Blob Storage** component.
55+
1. Under **Triggers**, select the **When a blob is added or modified (properties only) (V2)** trigger.
56+
1. Set the storage connection.
57+
58+
After creating a **When a blob is added or modified (properties only) (V2)** trigger, the connection needs to be set to the following values:
59+
60+
|Key | Value|
61+
|--|--|
62+
|Connection name | <*Name your connection*>. |
63+
|Authentication type | Access Key|
64+
|Azure Storage Account name| <*Storage account name where media files are going to be stored*>.|
65+
|Azure Storage Account Access Key| To get access key of your storage account: in the Azure portal -> my-storage -> under **Security + networking** -> **Access keys** -> copy one of the keys.|
66+
67+
Select **Create**.
68+
69+
![Screenshot of the storage connection trigger.](./media/logic-apps-connector-arm-accounts/trigger.png)
70+
71+
After setting the connection to the storage, it's required to specify the blob storage container that is being monitored for changes.
72+
73+
|Key| Value|
74+
|--|--|
75+
|Storage account name | *Storage account name where media files are stored*|
76+
|Container| `/videos`|
77+
78+
Select **Save** -> **+New step**
79+
80+
![Screenshot of the storage container trigger.](./media/logic-apps-connector-arm-accounts/storage-container-trigger.png)
81+
1. Create SAS URI by path action.
82+
83+
1. Select the **Action** tab.
84+
1. Search for and select **Create SAS URI by path (V2)**.
85+
86+
|Key| Value|
87+
|--|--|
88+
|Storage account name | <*The storage account name where media files as stored*>.|
89+
| Blob path| Under **Dynamic content**, select **List of Files Path**|
90+
| Group Policy Identifier| Leave the default value.|
91+
| Permissions| **Read** |
92+
| Shared Access protocol (appears after pressing **Add new parameter**)| **HttpsOnly**|
93+
94+
Select **Save** (at the top of the page).
95+
96+
![Screenshot of the create SAS URI by path logic.](./media/logic-apps-connector-arm-accounts/create-sas.png)
97+
98+
Select **+New Step**.
99+
1. Generate an access token.
100+
101+
> [!NOTE]
102+
> For details about the ARM API and the request/response examples, see [Generate an Azure Video Indexer access token](/rest/api/videoindexer/generate/access-token?tabs=HTTP).
103+
>
104+
> Press **Try it** to get the correct values for your account.
105+
106+
Search and create an **HTTP** action.
107+
108+
|Key| Value|
109+
|----|----|
110+
|Method | **POST**|
111+
| URI| `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts/{accountName}/generateAccessToken?api-version={API-version}`. |
112+
| Body|`{ "permissionType": "Contributor", "scope": "Account" }` |
113+
| Add new parameter | **Authentication** |
114+
115+
![Screenshot of the HTTP access token.](./media/logic-apps-connector-arm-accounts/http-with-param.png)
116+
117+
After the **Authentication** parameter is added, fill the required parameters according to the table below:
118+
119+
|Key| Value|
120+
|----|----|
121+
| Authentication type | **Managed identity** |
122+
| Managed identity | **System-assigned managed identity**|
123+
| Audience | `https://management.core.windows.net` |
124+
125+
Select **Save**.
126+
127+
> [!TIP]
128+
> Before moving to the next step step up the right permission between the Logic app and the Azure Video Indexer account.
129+
>
130+
> Make sure you have followed the steps to enable the system -assigned managed identity of your Logic Apps.
131+
132+
![Screenshot of the how to enable the system assigned managed identity.](./media/logic-apps-connector-arm-accounts/enable-system.png)
133+
1. Set up system assigned managed identity for permission on Azure Video Indexer resource.
134+
135+
In the Azure portal, go to your Azure Video Indexer resource/account.
136+
137+
1. On the left side blade, and select **Access control**.
138+
1. Select **Add** -> **Add role assignment** -> **Contributor** -> **Next** -> **User, group, or service principal** -> **+Select members**.
139+
1. Under **Members**, search for the Logic Apps name you created (in this case, `UploadIndexVideosApp`).
140+
1. Press **Select**.
141+
1. Press **Review + assign**.
142+
1. Back in your Logic App, create an **Upload video and index** action.
143+
144+
1. Select **Video Indexer(V2)**.
145+
1. From Video Indexer(V2) chose **Upload Video and index**.
146+
1. Set the connection to the Video Indexer account.
147+
148+
|Key| Value|
149+
|----|----|
150+
| Connection name| <*Enter a name for the connection*>, in this case `aviconnection`.|
151+
| API key| This is your personal API key, which is available under **Profile** in the [developer portal](https://api-portal.videoindexer.ai/profile)|
152+
153+
Select **Create**.
154+
1. Fill **Upload video and index** action parameters.
155+
156+
> [!TIP]
157+
> If the AVI Account ID cannot be found and isn't in the drop-down, use the custom value.
158+
159+
|Key| Value|
160+
|----|----|
161+
|Location| Location of the associated the Azure Video Indexer account.|
162+
| Account ID| Account ID of the associated Azure Video Indexer account. You can find the **Account ID** in the **Overview** page of your account, in the Azure portal. Or, the **Account settings** tab, left of the [Azure Video Indexer website](https://www.videoindexer.ai/).|
163+
|Access Token| Select **accessToken** from the **dynamic content** of the **Parse JSON** action.|
164+
| Video Name| Select **List of Files Name** from the dynamic content of **When a blob is added or modified** action. |
165+
|Video URL|Select **Web Url** from the dynamic content of **Create SAS URI by path** action.|
166+
| Body| Can be left as default.|
167+
168+
![Screenshot of the upload and index action.](./media/logic-apps-connector-arm-accounts/upload-and-index.png)
169+
170+
The completion of the uploading and indexing from the first flow will send an HTTP request with the correct callback URL to trigger the second flow. Then, it will retrieve the insights generated by Azure Video Indexer. In this example, it will store the output of your indexing job in your Azure Storage. However, it's up to you what you do with the output.
171+
172+
## Create a second flow - JSON extraction
173+
174+
Create the second flow, Logic Apps of type consumption. The second flow is triggered based on the callback URL and saves the extracted insights back to a JSON file in Azure Storage.
175+
176+
![Screenshot of the high level flow.](./media/logic-apps-connector-arm-accounts/second-flow-high-level.png)
177+
178+
1. Set up the trigger
179+
180+
Search for the **When an HTTP request is received**.
181+
182+
![Screenshot of the set up the trigger.](./media/logic-apps-connector-arm-accounts/serach-trigger.png)
183+
184+
For the trigger, we'll see an HTTP POST URL field. The URL won’t be generated until after you save your flow; however, you'll need the URL eventually.
185+
186+
> [!TIP]
187+
> We will come back to the URL created in this step.
188+
1. Generate an access token.
189+
190+
Follow all the steps from:
191+
192+
1. **Generate an access token** we did for the first flow.
193+
1. Select **Save** -> **+ New step**.
194+
1. Get Video Indexer insights.
195+
196+
1. Search for "Video Indexer".
197+
1. From **Video Indexer(V2)** chose **Get Video Index** action.
198+
199+
Set the connection name:
200+
201+
|Key| Value|
202+
|----|----|
203+
|Connection name| <*A name for connection*>. For example, `aviconnection`.|
204+
| API key| This is your personal API key, which is available under **Profile** at the [developer portal](https://api-portal.videoindexer.ai/profile). For more information, see [Subscribe to the API](video-indexer-use-apis.md#subscribe-to-the-api).|
205+
1. Select **Create**.
206+
1. Fill out the required parameters according to the table:
207+
208+
|Key| Value|
209+
|----|----|
210+
|Location| The Location of the Azure Video Indexer account.|
211+
| Account ID| The Video Indexer account ID can be copied from the resource/account **Overview** page in the Azure portal.|
212+
| Video ID\*| For Video ID, add dynamic content of type **Expression** and put in the following expression: **triggerOutputs()['queries']['id']**. |
213+
| Access Token| From the dynamic content, under the **Parse JSON** section select the **accessToken** that is the output of the parse JSON action. |
214+
215+
\*This expression tells the connecter to get the Video ID from the output of your trigger. In this case, the output of your trigger will be the output of **Upload video and index** in your first trigger.
216+
217+
![Screenshot of the upload and index a video action.](./media/logic-apps-connector-arm-accounts/get-video-index.png)
218+
219+
Select **Save** -> **+ New step**.
220+
1. Create a blob and store the insights JSON.
221+
222+
1. Search for "Azure blob", from the group of actions.
223+
1. Select **Create blob(V2)**.
224+
1. Set the connection to the blob storage that will store the JSON insights files.
225+
226+
|Key| Value|
227+
|----|----|
228+
| Connection name| <*Enter a connection name*>.|
229+
| Authentication type |Access Key|
230+
| Azure Storage Account name| <* The storage account name where insights will be stored*>. |
231+
| Azure Storage Account Access key| Go to Azure portal-> my-storage-> under **Security + networking** ->Access keys -> copy one of the keys. |
232+
233+
![Screenshot of the create blob action.](./media/logic-apps-connector-arm-accounts/storage-connection.png)
234+
1. Select **Create**.
235+
1. Set the folder in which insights will be stored.
236+
237+
|Key| Value|
238+
|----|----|
239+
|Storage account name| <*Enter the storage account name that would contain the JSON output (in this tutorial is the same as the source video).>*|
240+
| Folder path | From the dropdown, select the `/insights`|
241+
| Blob name| From the dynamic content, under the **Get Video Index** section select **Name** and add `_insights.json`, insights file name will be the video name + insights.json |
242+
| Blob content| From the dynamic content, under the **Get Video Index** section, select the **Body**. |
243+
244+
![Screenshot of the store blob content action.](./media/logic-apps-connector-arm-accounts/create-blob.png)
245+
1. Select **Save flow**.
246+
1. Update the callback URL to get notified when an index job is finished.
247+
248+
Once the flow is saved, an HTTP POST URL is created in the trigger.
249+
250+
1. Copy the URL from the trigger.
251+
252+
![Screenshot of the save URL trigger.](./media/logic-apps-connector-arm-accounts/http-callback-url.png)
253+
1. Go back to the first flow and paste the URL in the **Upload video and index** action for the **Callback URL parameter**.
254+
255+
Make sure both flows are saved.
256+
257+
## Next steps
258+
259+
Try out your newly created Logic App or Power Automate solution by adding a video to your Azure blobs container, and go back a few minutes later to see that the insights appear in the destination folder.
13.4 KB
Loading
74.6 KB
Loading
79.7 KB
Loading
11.4 KB
Loading
39.5 KB
Loading
13.4 KB
Loading
44.5 KB
Loading
57.6 KB
Loading
49.3 KB
Loading

0 commit comments

Comments
 (0)