×
Search results provided by Azure Search - read how I built it in this post.
Max Melcher

1 minute read

Run Azure Search indexer during Azure DevOps build

As described in my last post, I switched to Azure Search for my site search. And because I use Azure DevOps for publishing new blog posts, I wanted to trigger an index run from my build pipeline.

Surprisingly there is no Azure CLI command to trigger an index run, but there is a REST operation available. So I quickly created this PowerShell script:

$params = @{
 "api-key"="[ADMIN KEY]";
}

Invoke-WebRequest -Uri https://[SERVICE NAME].search.windows.net/indexers/[INDEXER NAME]/run?api-version=2017-11-11 -Method POST -Headers $params -UseBasicParsing
You only have to replace all the [] values.

I then added it to my Azure DevOps build:

I discovered, that if you run this command on self-hosted build agent, then it fails without the -UseBasicParsing switch.

So once a new build is running, the Azure Search index gets updated.

Hope it helps,
Max

comments powered by Disqus