Skip to content

Commit

Permalink
feat: add search ingredient
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Brown committed Jan 29, 2025
1 parent 84659cd commit f2f4364
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
1 change: 1 addition & 0 deletions ingredient/ingredient-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/node": "^10.12.18"
},
"dependencies": {
"@azbake/arm-helper": "^0.1.112",
"@azure/arm-search": "^3.2.0"
}
}
5 changes: 3 additions & 2 deletions ingredient/ingredient-search/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SearchPlugIn } from './plugin'
import { SearchUtils } from './functions'

exports.plugin = null
exports.pluginNS = null
exports.plugin = SearchPlugIn
exports.pluginNS = "@azbake/ingredient-search"

exports.functions = SearchUtils
exports.functionsNS = "search"
39 changes: 39 additions & 0 deletions ingredient/ingredient-search/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

import { BaseIngredient, IngredientManager } from "@azbake/core"
import { ARMHelper } from "@azbake/arm-helper"
import ARMTemplate from "./search.json"

const path = require("path")

export class SearchPlugIn extends BaseIngredient {

private resourceGroup: string = ""

public async Execute(): Promise<void> {
try {
let util = IngredientManager.getIngredientFunction("coreutils", this._ctx)
this._logger.log("Search ingredient logging");

const helper = new ARMHelper(this._ctx);

let params = await helper.BakeParamsToARMParamsAsync(this._name, this._ingredient.properties.parameters)

// define resource group
let rgOverrideParam = this._ingredient.properties.parameters.get('rgOverride')
if (rgOverrideParam) {
this.resourceGroup = await rgOverrideParam.valueAsync(this._ctx)
// remove rgOverride if it exists since its not in the ARM template
delete params["rgOverride"]
}
else {
this.resourceGroup = await util.resource_group();
}

await helper.DeployTemplate(this._name, ARMTemplate, params, this.resourceGroup)

} catch(error){
this._logger.error('deployment failed: ' + error)
throw error
}
}
}
54 changes: 54 additions & 0 deletions ingredient/ingredient-search/src/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"name": {
"type": "string"
},
"sku": {
"type": "string",
"defaultValue": "basic"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Search/searchServices",
"apiVersion": "2024-06-01-preview",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('sku')]"
},
"identity": {
"type": "SystemAssigned"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"hostingMode": "default",
"publicNetworkAccess": "Enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"encryptionWithCmk": {
"enforcement": "Unspecified"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"disabledDataExfiltrationOptions": [],
"semanticSearch": "free"
}
}
]
}

0 comments on commit f2f4364

Please sign in to comment.