From 77681401d2d2cf8c9c0303df4ca00c7b335d51c7 Mon Sep 17 00:00:00 2001 From: tanujbhatia1708 <89528919+tanujbhatia1708@users.noreply.github.com> Date: Wed, 5 Jul 2023 00:34:05 +0530 Subject: [PATCH] feat: Bicep Module for Bing Resource (#407) ## Description If you haven't already, read the full [contribution guide](https://github.com/Azure/bicep-registry-modules/blob/main/CONTRIBUTING.md). The guide may have changed since the last time you read it, so please double-check. Once you are done and ready to submit your PR, edit the PR description and run through the relevant checklist below. Enable GitHub Worksflows in your fork to enable auto-generation of assets with our [GitHub Action](/.github/workflows/push-auto-generate.yml). To trigger GitHub Actions after auto-generation, [add a GitHub PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) as a secret in your forked repository called `PAT`. ## Adding a new module - [x] A proposal has been submitted and approved. - [x] I have included "Closes #{module_proposal_issue_number}" in the PR description. - [x] I have run `brm validate` locally to verify the module files. - [x] I have run deployment tests locally to ensure the module is deployable. ## Updating an existing module - [ ] This is a bug fix: - [ ] Someone has opened a bug report issue, and I have included "Closes #{[bug_report_issue_number](https://github.com/Azure/bicep-registry-modules/issues/401)}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] I have run `brm validate` locally to verify the module files. - [ ] I have run deployment tests locally to ensure the module is deployable. - [ ] I have read the [Updating an existing module](https://github.com/Azure/bicep-registry-modules/blob/main/CONTRIBUTING.md#updating-an-existing-module) section in the contributing guide and updated the `version.json` file properly: - [ ] The PR contains backwards compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`. - [ ] The PR contains backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] The PR contains breaking changes, and I have bumped the MAJOR version in `version.json`. - [ ] I have updated the examples in README with the latest module version number. --------- Co-authored-by: tanujbhatia1708 Co-authored-by: Alan Silva Co-authored-by: OmegaVVeapon Co-authored-by: Daniel Ciborowski --- modules/ai/bing-resource/README.md | 61 ++++++++++ modules/ai/bing-resource/main.bicep | 65 ++++++++++ modules/ai/bing-resource/main.json | 113 ++++++++++++++++++ modules/ai/bing-resource/metadata.json | 6 + modules/ai/bing-resource/test/main.test.bicep | 33 +++++ modules/ai/bing-resource/version.json | 8 ++ 6 files changed, 286 insertions(+) create mode 100644 modules/ai/bing-resource/README.md create mode 100644 modules/ai/bing-resource/main.bicep create mode 100644 modules/ai/bing-resource/main.json create mode 100644 modules/ai/bing-resource/metadata.json create mode 100644 modules/ai/bing-resource/test/main.test.bicep create mode 100644 modules/ai/bing-resource/version.json diff --git a/modules/ai/bing-resource/README.md b/modules/ai/bing-resource/README.md new file mode 100644 index 0000000000..5145762bf6 --- /dev/null +++ b/modules/ai/bing-resource/README.md @@ -0,0 +1,61 @@ +# Bing Resource + +This module deploys Azure Bing Resource + +## Description + +Azure Bing resource refers to the integration of Bing's search capabilities into the Azure platform. Azure provides the Azure Cognitive Search service, which allows you to incorporate powerful search functionality, including web search, image search, news search, video search, and more, using Bing's search algorithms. +This Bicep Module helps to create Bing Search Kind resource. You may need to register Microsoft/Bing resource provider for your subscription before using this module. + +## Parameters + +| Name | Type | Required | Description | +| :------------------ | :------: | :------: | :---------------------------------------------------------------------------------------------------------- | +| `prefix` | `string` | No | Prefix of Resource Name. Not used if name is provided | +| `location` | `string` | No | The location into which your Azure resources should be deployed. | +| `name` | `string` | No | The name of the Bing Service. | +| `kind` | `string` | No | Optional. This parameter will define Bing search kind. | +| `skuName` | `string` | No | Optional. The name of the SKU, F* (free) and S* (standard). Supported SKUs will differ based on search kind | +| `statisticsEnabled` | `bool` | No | Optional. Enable or disable Bing statistics. | +| `tags` | `object` | No | Optional. Tags of the resource. | + +## Outputs + +| Name | Type | Description | +| :--------- | :------: | :-------------- | +| `id` | `string` | Bing account ID | +| `endpoint` | `string` | Bing Endpoint | + +## Examples + +### Example 1 + +Deploy a Bing Search v7 resource with the free SKU + +``` +module bing-search-resource 'br/public:ai/bing-resource:1.0.1' = { + name: 'bing-search-resource' + params: { + kind: 'Bing.Search.v7' + location: 'global' + name: 'bing-search-resource-name-01' + skuName: 'S1' + } +} +``` + +### Example 2 + +Deploy a Bing Custom Search resource with the standard SKU + +``` +module bing-search-resource 'br/public:ai/bing-resource:1.0.1' = { + name: 'bing-search-resource' + params: { + kind: 'Bing.CustomSearch' + location: 'global' + name: 'bing-search-resource-name-02' + skuName: 'S1' + } +} +``` \ No newline at end of file diff --git a/modules/ai/bing-resource/main.bicep b/modules/ai/bing-resource/main.bicep new file mode 100644 index 0000000000..28299fba85 --- /dev/null +++ b/modules/ai/bing-resource/main.bicep @@ -0,0 +1,65 @@ +@description('Prefix of Resource Name. Not used if name is provided') +param prefix string = 'bng' + +@description('The location into which your Azure resources should be deployed.') +param location string = resourceGroup().location + +@minLength(2) +@maxLength(64) +// Must contain only lowercase letters, hyphens and numbers +// Must contain at least 2 through 64 characters +// Can't start or end with hyphen +@description('The name of the Bing Service.') +param name string = take('${prefix}-${kind}-${uniqueString(resourceGroup().id, location)}', 64) + +@description('Optional. This parameter will define Bing search kind.') +@allowed( + [ + 'Bing.Search.v7' + 'Bing.CustomSearch' + ] +) +param kind string = 'Bing.Search.v7' + +@description('Optional. The name of the SKU, F* (free) and S* (standard). Supported SKUs will differ based on search kind') +@allowed( + [ + 'F0' + 'F1' + 'S1' + 'S2' + 'S3' + 'S4' + 'S5' + 'S6' + 'S7' + 'S8' + 'S9' + ] +) +param skuName string = 'F1' + +@description('Optional. Enable or disable Bing statistics.') +param statisticsEnabled bool = false + +@description('Optional. Tags of the resource.') +param tags object = {} + +resource BingAccount 'Microsoft.Bing/accounts@2020-06-10' = { + name: name + location: location + tags: tags + + kind: kind + properties: { + statisticsEnabled: statisticsEnabled + } + sku: { + name: skuName + } +} + +@description('Bing account ID') +output id string = BingAccount.id +@description('Bing Endpoint') +output endpoint string = BingAccount.properties.endpoint diff --git a/modules/ai/bing-resource/main.json b/modules/ai/bing-resource/main.json new file mode 100644 index 0000000000..7ac9038d71 --- /dev/null +++ b/modules/ai/bing-resource/main.json @@ -0,0 +1,113 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.18.4.5664", + "templateHash": "5128592152439671358" + } + }, + "parameters": { + "prefix": { + "type": "string", + "defaultValue": "bng", + "metadata": { + "description": "Prefix of Resource Name. Not used if name is provided" + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "The location into which your Azure resources should be deployed." + } + }, + "name": { + "type": "string", + "defaultValue": "[take(format('{0}-{1}-{2}', parameters('prefix'), parameters('kind'), uniqueString(resourceGroup().id, parameters('location'))), 64)]", + "metadata": { + "description": "The name of the Bing Service." + }, + "maxLength": 64, + "minLength": 2 + }, + "kind": { + "type": "string", + "defaultValue": "Bing.Search.v7", + "allowedValues": [ + "Bing.Search.v7", + "Bing.CustomSearch" + ], + "metadata": { + "description": "Optional. This parameter will define Bing search kind." + } + }, + "skuName": { + "type": "string", + "defaultValue": "F1", + "allowedValues": [ + "F0", + "F1", + "S1", + "S2", + "S3", + "S4", + "S5", + "S6", + "S7", + "S8", + "S9" + ], + "metadata": { + "description": "Optional. The name of the SKU, F* (free) and S* (standard). Supported SKUs will differ based on search kind" + } + }, + "statisticsEnabled": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Optional. Enable or disable Bing statistics." + } + }, + "tags": { + "type": "object", + "defaultValue": {}, + "metadata": { + "description": "Optional. Tags of the resource." + } + } + }, + "resources": [ + { + "type": "Microsoft.Bing/accounts", + "apiVersion": "2020-06-10", + "name": "[parameters('name')]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]", + "kind": "[parameters('kind')]", + "properties": { + "statisticsEnabled": "[parameters('statisticsEnabled')]" + }, + "sku": { + "name": "[parameters('skuName')]" + } + } + ], + "outputs": { + "id": { + "type": "string", + "metadata": { + "description": "Bing account ID" + }, + "value": "[resourceId('Microsoft.Bing/accounts', parameters('name'))]" + }, + "endpoint": { + "type": "string", + "metadata": { + "description": "Bing Endpoint" + }, + "value": "[reference(resourceId('Microsoft.Bing/accounts', parameters('name')), '2020-06-10').endpoint]" + } + } +} \ No newline at end of file diff --git a/modules/ai/bing-resource/metadata.json b/modules/ai/bing-resource/metadata.json new file mode 100644 index 0000000000..2e9f816bc2 --- /dev/null +++ b/modules/ai/bing-resource/metadata.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://aka.ms/bicep-registry-module-metadata-file-schema-v2#", + "name": "Bing Resource", + "summary": "This module deploys Azure Bing Resource", + "owner": "tanujbhatia1708" +} \ No newline at end of file diff --git a/modules/ai/bing-resource/test/main.test.bicep b/modules/ai/bing-resource/test/main.test.bicep new file mode 100644 index 0000000000..05bce6623f --- /dev/null +++ b/modules/ai/bing-resource/test/main.test.bicep @@ -0,0 +1,33 @@ +/* +Write deployment tests in this file. Any module that references the main +module file is a deployment test. Make sure at least one test is added. +*/ + +targetScope = 'resourceGroup' +// ===== // +// Tests // +// ===== // + +// Test-01 - Bing Search v7 resource + +module test_01_Bing '../main.bicep' = { + name: 'test_01_Bing_resource' + params: { + location: 'global' + kind: 'Bing.Search.v7' + name: 'Bing_SearchTest01' + skuName: 'S1' + } +} + +// Test-02 - Bing Custom Search resource test + +module test_02_Bing '../main.bicep' = { + name: 'test_02_Bing_resource' + params: { + location: 'global' + kind: 'Bing.CustomSearch' + name: 'Bing_SearchTest02' + skuName: 'S1' + } +} diff --git a/modules/ai/bing-resource/version.json b/modules/ai/bing-resource/version.json new file mode 100644 index 0000000000..e40897e287 --- /dev/null +++ b/modules/ai/bing-resource/version.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", + "version": "1.0", + "pathFilters": [ + "./main.json", + "./metadata.json" + ] +} \ No newline at end of file