Use with a Logic Apps connector
Azure AI Video Indexer (VI) REST API supports both server-to-server and client-to-server communication. The API enables you to integrate video and audio insights into your application logic.
We support Logic Apps and Power Automate connectors that are compatible with the Azure AI Video Indexer API.
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. Using the connectors for the integration gives you visibility on the health of your workflow and a way to debug it.
The example in this article creates Logic App flows. The Logic App and Power Automate capabilities and their editors are almost identical.
The two flow approach, two flows that work together, supports async upload and indexing of larger files effectively.
- The first flow is triggered when a blob is added or modified in an Azure Storage account. It uploads the new file to Azure AI Video Indexer with a callback URL to send a notification once the indexing operation completes.
- The second flow is triggered based on the callback URL and saves the extracted insights back to a JSON file in Azure Storage.
The logic apps you create in this article contain one flow per app. The second section, Create a new logic app of type consumption explains how to connect the two. The second flow stands alone and is triggered by the first one.
When a file is uploaded and indexed from the first flow, it sends an HTTP request with the correct callback URL to trigger the second flow. Then, it will retrieve the insights generated by Azure AI 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.
- If you don't have an Azure subscription, create an Azure free account before you begin.
- Create an ARM-based Azure AI Video Indexer account.
- Create an Azure Storage account. Storage accounts for VI must be a Standard general-purpose v2 storage account. Keep note of the access key for your Storage account.
- Create two containers: one to store the media files, second to store the insights generated by Azure AI Video Indexer. In this article, the containers are
videos
andinsights
.
- Create two containers: one to store the media files, second to store the insights generated by Azure AI Video Indexer. In this article, the containers are
- Generate an access token using the generateAccessToken. Press Try it to get the correct values for your account.
- Copy and paste it to Notepad for a later step.
This section describes how to set up the first, file upload, 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 AI Video Indexer with a callback URL to send a notification once the indexing operation completes.
The flow steps are:
- When a blob is added or modified (properties only) (V2)
- Create SAS URI by path (V2)
- HTTP
- Upload video and index
Create the Logic App in the same region as the Azure Video Indexer account region (recommended but not required).
Call the logic app
UploadIndexVideosApp
.- Select Consumption for Plan type.
- Press Review + Create -> Create.
- Once the Logic App deployment is complete, in the Azure portal, search and navigate to the newly created Logic App.
- Under the Settings section, on the left side's panel, select the Identity tab.
- Under System assigned, change the Status from Off to On (the step is important for later on in this tutorial).
- Press Save (on the top of the page).
- Select the Logic app designer tab, in the pane on the left.
- Pick a Blank Logic App flow.
- Search for "blob" in the Choose an Operation blade.
- In the All tab, choose the Azure Blob Storage component.
- Under Triggers, select the When a blob is added or modified (properties only) (V2) trigger.
Create a When a blob is added or modified (properties only) (V2) trigger.
Set the storage connection to these values:
Key Value Connection name <Name your connection>. Authentication type Access Key Azure Storage Account name <Storage account name where media files are going to be stored>. 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. - Select Create.
- Specify the blob storage container that is monitored for changes.
Key Value Storage account name Storage account name where media files are stored Container /videos
- Select Save ->
Select +New step
Create SAS URI by path action.
- Select the Action tab.
- Search for and select Create SAS URI by path (V2).
Key Value Storage account name <The storage account name where media files as stored>. Blob path Under Dynamic content, select List of Files Path Group Policy Identifier Leave the default value. Permissions Read Shared Access protocol (appears after pressing Add new parameter) HttpsOnly - Select Save.
Select +New Step.
Search for and create an HTTP action using the values in the following table:
Key Value Notes Method POST URI [Access token](#generate-an-access token) Body { "permissionType": "Contributor", "scope": "Account" }
See the REST doc example, make sure to delete the POST line. Add new parameter Authentication - Fill the required parameters for authentication according to the following table:
Key Value Authentication type Managed identity Managed identity System-assigned managed identity Audience https://management.core.windows.net
- Select Save.
Set up the permissions between the Logic app and the Azure AI Video Indexer account.
Set up system assigned managed identity for permission on Azure AI Video Indexer resource. In the Azure portal, go to your Azure AI Video Indexer resource/account.
- On the left side blade, and select Access control.
- Select Add -> Add role assignment -> Contributor -> Next -> User, group, or service principal -> +Select members.
- Under Members, search for the Logic Apps name you created (in this case,
UploadIndexVideosApp
). - Press Select.
- Press Review + assign.
Select Video Indexer(V2).
From Video Indexer(V2), select Upload Video and index.
Set the connection to the Video Indexer account with the parameters in the following table:
Key Value Connection name <Enter a name for the connection>, in this case aviconnection
.API key This is your personal API key, which is available under Profile in the developer portal Because this Logic App is for ARM accounts we do not need the actual API key and you can fill in a dummy value like 12345 Select Create.
Fill Upload video and index action parameters.
Tip
If the VI Account ID cannot be found and isn't in the drop-down, use the custom value.
Key Value Location Location of the associated the Azure AI Video Indexer account. Account ID Account ID of the associated Azure AI 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 AI Video Indexer website. Access Token Use the body('HTTP')['accessToken']
expression to extract the access token in the right format from the previous HTTP call.Video Name Select List of Files Name from the dynamic content of When a blob is added or modified action. Video URL Select Web Url from the dynamic content of Create SAS URI by path action. Body Can be left as default. Select Save.
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.
The flow steps are:
- When a HTTP request is received
- HTTP
- Get Video Index
- Create blob (V2)
Search for and select the When an HTTP request is received.
For the trigger, there is a HTTP POST URL field. The URL won’t be generated until after you save your flow; however, you'll need the URL eventually.
Tip
We will come back to the URL created in this step.
You might need to generate another access token depending on how you set up the first one. Copy and paste it into Notepad.
- Generate an access token.
- Select Save -> + New step.
Search for "Video Indexer".
From Video Indexer(V2), select the Get Video Index action.
Set the connection name:
Key Value Connection name <A name for connection>. For example, aviconnection
.API key This is your personal API key, which is available under Profile at the developer portal. For more information, see Subscribe to the API. Select Create.
Fill out the required parameters according to the table:
Key Value Location The Location of the Azure AI Video Indexer account. Account ID The Video Indexer account ID can be copied from the resource/account Overview page in the Azure portal. Video ID* For Video ID, add dynamic content of type Expression and put in the following expression: triggerOutputs()['queries']['id']. Access Token From the dynamic content, under the Parse JSON section select the accessToken that is the output of the parse JSON action. *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.
Select Save -> + New step.
Search for "Azure blob", from the group of actions.
Select Create blob(V2).
Set the connection to the blob storage that will store the JSON insights files.
Key Value Connection name <Enter a connection name>. Authentication type Access Key Azure Storage Account name <* The storage account name where insights will be stored*>. Azure Storage Account Access key Go to Azure portal-> my-storage-> under Security + networking ->Access keys -> copy one of the keys. - Select Create.
- Set the folder in which insights will be stored.
Key Value Storage account name <Enter the storage account name that would contain the JSON output (in this tutorial is the same as the source video).> Folder path From the dropdown, select the /insights
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.jsonBlob content From the dynamic content, under the Get Video Index section, select the Body. - Select Save flow.
Once the flow is saved, an HTTP POST URL is created in the trigger.
- Copy the URL from the trigger.
- Go back to the first flow and paste the URL in the Upload video and index action for the Callback URL parameter.
Make sure both flows are saved.