Azure-Samples / Azure-Samples/azure-search-deployment-template
Include example for using `index.json` or `indexer.json` for configs vs. hard-coded defs in PowerShell script
- Dominant language
- Bicep
- Stars
- 6
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
In the PowerShell scripts, the index, indexer [are defined in-line](https://github.com/Azure-Samples/azure-search-deployment-template/blob/main/bicep/SetupSearchService.ps1#L23-L29). Could be helpful to include an example where one of these is a JSON config.
Steps for adding:
- In [`setup-search-service.bicep`](https://github.com/Azure-Samples/azure-search-deployment-template/blob/main/bicep/setup-search-service.bicep) read in the file:
- `var indexJson = loadJsonContent('index.json')`
- Pass JSON data as [argument to script](https://github.com/Azure-Samples/azure-search-deployment-template/blob/main/bicep/setup-search-service.bicep#L49)
- `...-indexJson \\"${indexJson}\\"'`
- In [`SetupSearchService.ps1`](https://github.com/Azure-Samples/azure-search-deployment-template/blob/main/bicep/SetupSearchService.ps1) update to use:
- `...[string] [Parameter(Mandatory=$true)] $indexJsonStr` in `param` def
- `$indexDefinition = $indexJsonStr | ConvertFrom-Json`
- Switch `$indexDefinition['name']` references to `$indexDefinition.name`
- When sending [body to PUT](https://github.com/Azure-Samples/azure-search-deployment-template/blob/main/bicep/SetupSearchService.ps1#L59):
- `-Body $indexJsonStr` NOT the JSON object
Contributor guide
Assessment
This issue has not been assessed yet.