@Matt Dorsey Thanks for reaching out. You can execute run indexer REST API as you do in any of your C# code. To get more familiar with Cognitive Search Service REST you can refer to this document. Sharing a few references on how to call any service but you need to update the header/build the request as per the run indexer document.
https://stackoverflow.com/questions/56288606/best-approach-to-call-web-api-from-azure-function
https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client
Using .net/c# to run the cognitive search indexer
I've got a web application that allows users to regularly upload documents into an azure blob container. After upload I then run the Azure indexer service to make the documents available to search through. I'd like to automate the process of running the indexer after the user uploads their documents. I've started to develop this azure function using a blob trigger, but I'm having a difficult time coming up with the code to begin running the indexer... Is there an example I can look at?
Azure Functions
Azure AI Search
-
MayankBargali-MSFT 70,941 Reputation points Moderator
2022-07-14T06:40:34.607+00:00
1 additional answer
Sort by: Most helpful
-
MughundhanRaveendran-MSFT 12,506 Reputation points
2022-07-14T06:42:27.367+00:00 Hi @Matt Dorsey ,
Thanks for reaching out to Q&A forum.
According to Azure cognitive search documentation, you can configure and run the indexer on the blob files in the container via Rest API calls
POST https://[service name].search.windows.net/indexers?api-version=2020-06-30
{
"name" : "my-blob-indexer,
"dataSourceName" : "my-blob-datasource",
"targetIndexName" : "my-search-index",
"parameters": {
"batchSize": null,
"maxFailedItems": null,
"maxFailedItemsPerBatch": null,
"base64EncodeKeys": null,
"configuration:" {
"indexedFileNameExtensions" : ".pdf,.docx",
"excludedFileNameExtensions" : ".png,.jpeg",
"dataToExtract": "contentAndMetadata",
"parsingMode": "default"
}
},
"schedule" : { },
"fieldMappings" : [ ]
}You can make Rest API calls using Httpclient in C#. This can be implemented in .net based function app.
I hope this helps! Feel free to reach out to me if you have further queries or concerns.