项目作者: weather-balloon

项目描述 :
Deploys the search service into Azure
高级语言: Python
项目地址: git://github.com/weather-balloon/deploy-search.git
创建时间: 2019-08-31T04:39:32Z
项目社区:https://github.com/weather-balloon/deploy-search

开源协议:BSD 2-Clause "Simplified" License

下载


Azure Search configuration

Build Status

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:

The challenge

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:

  • Create an index if it doesn’t exist
  • Update an index if possible or drop/re-create if needed (forced)
  • Create/update an indexer
  • Run an indexer and check its status
  • Create/update a datasource
  • Delete an index/indexer/datasource

Running

The configure_search script provides a number of functions for setting up Azure Search. You can
check out the command with:

  1. 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’s
addSpnToEnvironment parameter.

When setting up a datasource you can pass in the connection string via the command line
or an environment variable:

  1. export connectionString="<CONNECTION STRING>"

You can see the deployment script in deploy/deploy-indexes.sh for an example
of using the configure_search tool.

References