Deploys the search service into Azure
Script and index definitions for deploying Azure Search indexes.
An Azure search service can be deployed with azuredeploy.json
. The azure-pipelines.yml
definition automates deployment using Azure Pipelines. Note that the default Azure Search SKU
is free
and this has limits that will prevent all of the data being indexed.
The indexes/
folder contains the index, datasource and indexer definitions:
postcodes
indexes the postcodes in the CSV file held in Blob storage.stations
indexes the weather station data in an Azure Storage Table.Azure Search always seems a little out of step with many of its Azure colleagues. The
setup of indexes is rather manual and requires either Portal- or API-based config
(i.e. no CLI). Further to this is the limited ability to udpate indexes and their related
datasources and indexers. This make it all a bit tricky in CD pipelines - it’s almost
like they need an Azure Search DACPAC…
So I wrote a little Python script to try and do some of the basics:
The configure_search
script provides a number of functions for setting up Azure Search. You can
check out the command with:
pipenv run ./configure_search -h
The ConfigArgParse library is used so that
you can set parameters in a file or environment variables. The azsearchconfig.empty
file
provides a template - just copy it to .azsearchconfig
and add your settings,
Note: The script can read the $servicePrincipalId
, $servicePrincipalKey
and $tenantId
environment variables or accept them as parameters. These were selected to match the
Azure CLI task’saddSpnToEnvironment
parameter.
When setting up a datasource you can pass in the connection string via the command line
or an environment variable:
export connectionString="<CONNECTION STRING>"
You can see the deployment script in deploy/deploy-indexes.sh
for an example
of using the configure_search
tool.