If you want to use a PDF document as source for ChatGPT prompt, you need to add it to search and index it first. For that you need to have the document in Azure BLOB and the URL for the document.

Main logic for the Power Automate flow is shown below

Each of the scopes follow the format of Premium Logging except using Azure Application Insights. Since this is child flow, on error it should respond to the parent flow with correct values and then stop executing the flow.

Create Data Source

Create data source for the document. The document is in the same storage account and container as the other but created into separate folder using a GUID (below picture RowID). Name of the data source is also the GUID. Main thing is that in the query (arrow in below picture) you set the folder name. This is how you target this data source for only this one document in the container.

Instructions Create Data Source (Azure Cognitive Search REST API)

Create Index

After the data source you need to create index and set there fields. You can create an index manually from Azure Portal and then copy the fields from there into this HTTP call.

I use as name of the index the same GUID as I have used for the data source and the folder inside the storage account container, where this specific document lies. Magically the document id is the GUID.

Instructions Create Index (Azure Cognitive Search REST API)

Create and Run Indexer

Now there is time to create indexer which will gather together the document source and the index defining the indexed fields. The name of this indexer is once again the same GUID.

Instructions Create Indexer (Azure Cognitive Search REST API)

Check Indexer Status

Before using the index in any query, it is very important to be sure the that the indexer has run successful. For that we need Do Until loop. We give there 15 seconds head start then first check. If the last run block is missing from the HTTP response, it will crash and I give 1 minute before trying again. Once there is this response, then we check the status of last run. If it is success, we step out of the loop and respond to parent flow that index is ok and ready to use.

Instructions Get Indexer Status (Azure Cognitive Search REST API)