From b3bc86566d08443511d374c4e571d600d6d7948f Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Wed, 21 Aug 2024 21:22:06 -0700 Subject: [PATCH] [Search] Migrate to Bicep (#30855) And update API versions Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4070243&view=results --- sdk/search/search-documents/test/README.md | 2 +- sdk/search/test-resources.bicep | 21 ++++++++ sdk/search/test-resources.json | 60 ---------------------- 3 files changed, 22 insertions(+), 61 deletions(-) create mode 100644 sdk/search/test-resources.bicep delete mode 100644 sdk/search/test-resources.json diff --git a/sdk/search/search-documents/test/README.md b/sdk/search/search-documents/test/README.md index b9d063c8d05..bc00951569e 100644 --- a/sdk/search/search-documents/test/README.md +++ b/sdk/search/search-documents/test/README.md @@ -2,7 +2,7 @@ To test this project, make sure to build it by following our [building instructions](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md#building), then follow the [testing instructions](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md#testing). -The Azure Cognitive Search client does not have any recorded tests and so, all the tests require an Azure Cognitive Search account to be set up beforehand. You can use existing Azure resources for the live tests, or generate new ones by using our [New-TestResources.ps1](https://github.com/Azure/azure-sdk-for-js/blob/main/eng/common/TestResources/New-TestResources.ps1) script, which will use an [ARM template](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/test-resources.json) that already has all of the the necessary configurations. +The Azure Cognitive Search client does not have any recorded tests and so, all the tests require an Azure Cognitive Search account to be set up beforehand. You can use existing Azure resources for the live tests, or generate new ones by using our [New-TestResources.ps1](https://github.com/Azure/azure-sdk-for-js/blob/main/eng/common/TestResources/New-TestResources.ps1) script, which will use a [Bicep template](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/test-resources.bicep) that already has all of the the necessary configurations. The Azure resource that is used by the tests in this project is: diff --git a/sdk/search/test-resources.bicep b/sdk/search/test-resources.bicep new file mode 100644 index 00000000000..22e67ac22a3 --- /dev/null +++ b/sdk/search/test-resources.bicep @@ -0,0 +1,21 @@ +param baseName string = resourceGroup().name +param searchEndpointSuffix string = 'search.windows.net' + +var apiVersion = '2024-06-01-preview' + +resource searchService 'Microsoft.Search/searchServices@2024-06-01-preview' = { + name: baseName + location: resourceGroup().location + sku: { + name: 'basic' + } + properties: { + replicaCount: 1 + partitionCount: 1 + hostingMode: 'default' + } +} + +output SEARCH_API_ADMIN_KEY string = listAdminKeys(searchService.id, apiVersion).primaryKey +output SEARCH_API_ADMIN_KEY_ALT string = listAdminKeys(searchService.id, apiVersion).secondaryKey +output ENDPOINT string = 'https://${baseName}.${searchEndpointSuffix}' diff --git a/sdk/search/test-resources.json b/sdk/search/test-resources.json deleted file mode 100644 index df178404aff..00000000000 --- a/sdk/search/test-resources.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "baseName": { - "type": "string", - "defaultValue": "[resourceGroup().name]", - "metadata": { - "description": "The base resource name." - } - }, - "searchSku": { - "type": "string", - "defaultValue": "basic", - "metadata": { - "description": "SKU for search resource. The default is 'basic'" - } - }, - "searchEndpointSuffix": { - "type": "string", - "defaultValue": "search.windows.net", - "metadata": { - "description": "Endpoint suffix for the search resource. Defaults to 'search.windows.net'" - } - } - }, - "variables": {}, - "resources": [ - { - "apiVersion": "2015-08-19", - "name": "[parameters('baseName')]", - "location": "[resourceGroup().location]", - "type": "Microsoft.Search/searchServices", - "sku": { - "name": "[parameters('searchSku')]" - }, - "properties": { - "replicaCount": 1, - "partitionCount": 1, - "hostingMode": "default" - }, - "tags": {}, - "dependsOn": [] - } - ], - "outputs": { - "SEARCH_API_ADMIN_KEY": { - "type": "string", - "value": "[listAdminKeys(resourceId('Microsoft.Search/searchServices', parameters('baseName')), '2015-08-19').primaryKey]" - }, - "SEARCH_API_ADMIN_KEY_ALT": { - "type": "string", - "value": "[listAdminKeys(resourceId('Microsoft.Search/searchServices', parameters('baseName')), '2015-08-19').secondaryKey]" - }, - "ENDPOINT": { - "type": "string", - "value": "[concat('https://', parameters('baseName'), '.', parameters('searchEndpointSuffix'))]" - } - } -}