-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bicep Module for Bing Resource (#407)
## Description <!--Why this PR? What is changed? What is the effect? etc.--> 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 <!--Run through the checklist if your PR adds 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 <!--Run through the checklist if your PR updates an existing module.--> - [ ] This is a bug fix: - [ ] Someone has opened a bug report issue, and I have included "Closes #{[bug_report_issue_number](#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 <[email protected]> Co-authored-by: Alan Silva <[email protected]> Co-authored-by: OmegaVVeapon <[email protected]> Co-authored-by: Daniel Ciborowski <[email protected]>
- Loading branch information
1 parent
4892fbc
commit 7768140
Showing
6 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", | ||
"version": "1.0", | ||
"pathFilters": [ | ||
"./main.json", | ||
"./metadata.json" | ||
] | ||
} |