Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Standard Agent Setup with Bing #14245

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
description: This set of templates demonstrates how to set up Azure AI Agent Service with the standard setup and bing, meaning with managed identity authentication of each project connection and public internet access enabled. The bing project connection uses api keys for authentication. Agents use customer-owned, single-tenant search and storage resources. With this setup, you have full control and visibility over these resources, but you will incur costs based on your usage.
page_type: sample
products:
- azure
- azure-resource-manager
- azure-ai-agent-service
urlFragment: standard-agent-bing
languages:
- bicep
- json
---
# Standard Agent Setup with Bing

Resources for the hub, project, storage account, key vault, AI Services, and Azure AI Search will be created for you. The AI Services, AI Search, and Azure Blob Storage account will be connected to your project/hub using managed identity for authentication and a gpt-4o-mini model will be deployed in the eastus region. A bing resource will be created and connected to your hub/project using an api key for authentication.

Optional use an existing AI Services, AI Search, Azure Blob Storage, and/or Bing resource by providing the full arm resource id in the parameters file:

- aiServiceAccountResourceId
- aiSearchServiceResourceId
- aiStorageAccountResourceId
- bingSearchResourceID

![Azure Public Test Date](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/PublicLastTestDate.svg)
![Azure Public Test Result](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/PublicDeployment.svg)

![Azure US Gov Last Test Date](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/FairfaxLastTestDate.svg)
![Azure US Gov Last Test Result](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/FairfaxDeployment.svg)

![Best Practice Check](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/BestPracticeResult.svg)
![Cred Scan Check](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/CredScanResult.svg)

![Bicep Version](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azure-ai-agent-service/standard-agent-bing/BicepVersion.svg)

[![Deploy To Azure](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazure.svg?sanitize=true)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.azure-ai-agent-service%2Fstandard-agent-bing%2Fazuredeploy.json)

[![Visualize](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.svg?sanitize=true)](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.azure-ai-agent-service%2Fstandard-agent-bing%2Fazuredeploy.json)

## Resources

| Provider and type | Description |
| - | - |
| `Microsoft.Resources/resourceGroups` | The resource group all resources get deployed into |
| `Microsoft.KeyVault/vaults` | An Azure Key Vault instance associated to the Azure Machine Learning workspace |
| `Microsoft.Storage/storageAccounts` | An Azure Storage instance associated to the Azure Machine Learning workspace |
| `Microsoft.MachineLearningServices/workspaces` | An Azure AI hub (Azure Machine Learning RP workspace of kind 'hub') |
| `Microsoft.MachineLearningServices/workspaces` | An Azure AI project (Azure Machine Learning RP workspace of kind 'project') |
| `Microsoft.CognitiveServices/accounts` | An Azure AI Services as the model-as-a-service endpoint provider (allowed kinds: 'AIServices' and 'OpenAI') |
| `Microsoft.CognitiveServices/accounts/deployments` | A gpt-4o-mini model is deployed |
| `Microsoft.Search/searchServices` | An Azure AI Search account |
| `Microsoft.Bing/accounts` | A Bing Resource |
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"aiHubName": {
"value": "hub-demo"
},
"aiHubFriendlyName": {
"value": "Agents Hub resource"
},
"aiHubDescription": {
"value": "This is an example AI resource for use in Azure AI Studio."
},
"aiProjectName": {
"value": "project-demo"
},
"aiProjectFriendlyName": {
"value": "Agents Project resource"
},
"aiProjectDescription": {
"value": "This is an example AI Project resource for use in Azure AI Studio."
},
"tags": {
"value": {}
},
"aiSearchName": {
"value": "agent-ai-search"
},
"capabilityHostName": {
"value": "caphost1"
},
"storageName": {
"value": "agent-storage"
},
"aiServicesName": {
"value": "agent-ai-services"
},
"modelName": {
"value": "gpt-4o-mini"
},
"modelFormat": {
"value": "OpenAI"
},
"modelVersion": {
"value": "2024-07-18"
},
"modelSkuName": {
"value": "GlobalStandard"
},
"modelCapacity": {
"value": 50
},
"modelLocation": {
"value": "eastus"
},
"aiServiceAccountResourceId": {
"value": ""
},
"aiSearchServiceResourceId": {
"value": ""
},
"aiStorageAccountResourceId":{
"value": ""
},
"bingSearchResourceID" : {
"value": ""
},
"bingName" : {
"value": "agent-bing-search"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
// Execute this main file to deploy Standard Agent setup resources

// Parameters
@minLength(2)
@maxLength(12)
@description('Name for the AI resource and used to derive name of dependent resources.')
param aiHubName string = 'hub-demo'

@description('Friendly name for your Hub resource')
param aiHubFriendlyName string = 'Agents Hub resource'

@description('Description of your Azure AI resource displayed in AI studio')
param aiHubDescription string = 'This is an example AI resource for use in Azure AI Studio.'

@description('Name for the AI project resources.')
param aiProjectName string = 'project-demo'

@description('Friendly name for your Azure AI resource')
param aiProjectFriendlyName string = 'Agents Project resource'

@description('Description of your Azure AI resource displayed in AI studio')
param aiProjectDescription string = 'This is an example AI Project resource for use in Azure AI Studio.'

@description('Azure region used for the deployment of all resources.')
param location string = resourceGroup().location

@description('Set of tags to apply to all resources.')
param tags object = {}

@description('Name of the Azure AI Search account')
param aiSearchName string = 'agent-ai-search'

@description('Name for capabilityHost.')
param capabilityHostName string = 'caphost1'

@description('Name of the storage account')
param storageName string = 'agent-storage'

@description('Name of the Azure AI Services account')
param aiServicesName string = 'agent-ai-services'

@description('Model name for deployment')
param modelName string = 'gpt-4o-mini'

@description('Model format for deployment')
param modelFormat string = 'OpenAI'

@description('Model version for deployment')
param modelVersion string = '2024-07-18'

@description('Model deployment SKU name')
param modelSkuName string = 'GlobalStandard'

@description('Model deployment capacity')
param modelCapacity int = 50

@description('Model deployment location. If you want to deploy an Azure AI resource/model in different location than the rest of the resources created.')
param modelLocation string = 'eastus'

@description('The AI Service Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
param aiServiceAccountResourceId string = ''

@description('The AI Search Service full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
param aiSearchServiceResourceId string = ''

@description('The AI Storage Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
param aiStorageAccountResourceId string = ''

@description('The full ARM Bing Resource ID. This is an optional field, and if not provided, the resource will be created.')
param bingSearchResourceID string = ''

@description('The Bing Search resource name')
param bingName string = 'agent-bing-search'

// Variables
var name = toLower('${aiHubName}')
var projectName = toLower('${aiProjectName}')

// Create a short, unique suffix, that will be unique to each resource group
// var uniqueSuffix = substring(uniqueString(resourceGroup().id), 0, 4)
param deploymentTimestamp string = utcNow('yyyyMMddHHmmss')
var uniqueSuffix = substring(uniqueString('${resourceGroup().id}-${deploymentTimestamp}'), 0, 4)

var aiServiceExists = aiServiceAccountResourceId != ''
var acsExists = aiSearchServiceResourceId != ''

var aiServiceParts = split(aiServiceAccountResourceId, '/')
var aiServiceAccountSubscriptionId = aiServiceExists ? aiServiceParts[2] : subscription().subscriptionId
var aiServiceAccountResourceGroupName = aiServiceExists ? aiServiceParts[4] : resourceGroup().name

var acsParts = split(aiSearchServiceResourceId, '/')
var aiSearchServiceSubscriptionId = acsExists ? acsParts[2] : subscription().subscriptionId
var aiSearchServiceResourceGroupName = acsExists ? acsParts[4] : resourceGroup().name

// Dependent resources for the Azure Machine Learning workspace
module aiDependencies 'modules-standard-bing/standard-dependent-resources-bing.bicep' = {
name: 'dependencies-${name}-${uniqueSuffix}-deployment'
params: {
location: location
storageName: '${storageName}${uniqueSuffix}'
keyvaultName: 'kv-${name}-${uniqueSuffix}'
aiServicesName: '${aiServicesName}${uniqueSuffix}'
aiSearchName: '${aiSearchName}-${uniqueSuffix}'
bingName: '${bingName}-${uniqueSuffix}'
tags: tags

// Model deployment parameters
modelName: modelName
modelFormat: modelFormat
modelVersion: modelVersion
modelSkuName: modelSkuName
modelCapacity: modelCapacity
modelLocation: modelLocation

aiServiceAccountResourceId: aiServiceAccountResourceId
aiSearchServiceResourceId: aiSearchServiceResourceId
aiStorageAccountResourceId: aiStorageAccountResourceId
bingSearchResourceID: bingSearchResourceID
}
}

module aiHub 'modules-standard-bing/standard-ai-hub-bing.bicep' = {
name: '${name}-${uniqueSuffix}-deployment'
params: {
// workspace organization
aiHubName: '${name}-${uniqueSuffix}'
aiHubFriendlyName: aiHubFriendlyName
aiHubDescription: aiHubDescription
location: location
tags: tags
capabilityHostName: '${name}-${uniqueSuffix}-${capabilityHostName}'

aiSearchName: aiDependencies.outputs.aiSearchName
aiSearchId: aiDependencies.outputs.aisearchID
aiSearchServiceResourceGroupName: aiDependencies.outputs.aiSearchServiceResourceGroupName
aiSearchServiceSubscriptionId: aiDependencies.outputs.aiSearchServiceSubscriptionId

aiServicesName: aiDependencies.outputs.aiServicesName
aiServicesId: aiDependencies.outputs.aiservicesID
aiServicesTarget: aiDependencies.outputs.aiservicesTarget
aiServiceAccountResourceGroupName:aiDependencies.outputs.aiServiceAccountResourceGroupName
aiServiceAccountSubscriptionId:aiDependencies.outputs.aiServiceAccountSubscriptionId

bingName: aiDependencies.outputs.bingName
bingId: aiDependencies.outputs.bingId
bingResourceGroupName: aiDependencies.outputs.bingResourceGroupName
bingSubscriptionId: aiDependencies.outputs.bingSubscriptionId

keyVaultId: aiDependencies.outputs.keyvaultId
storageAccountId: aiDependencies.outputs.storageId
}
}

module aiProject 'modules-standard-bing/standard-ai-project-bing.bicep' = {
name: '${projectName}-${uniqueSuffix}-deployment'
params: {
// workspace organization
aiProjectName: '${projectName}-${uniqueSuffix}'
aiProjectFriendlyName: aiProjectFriendlyName
aiProjectDescription: aiProjectDescription
location: location
tags: tags

// dependent resources
capabilityHostName: '${projectName}-${uniqueSuffix}-${capabilityHostName}'

aiHubId: aiHub.outputs.aiHubID
acsConnectionName: aiHub.outputs.acsConnectionName
aoaiConnectionName: aiHub.outputs.aoaiConnectionName
}
}

module aiServiceRoleAssignments 'modules-standard-bing/ai-service-role-assignments-bing.bicep' = {
name: 'ai-service-role-assignments-${projectName}-${uniqueSuffix}-deployment'
scope: resourceGroup(aiServiceAccountSubscriptionId, aiServiceAccountResourceGroupName)
params: {
aiServicesName: aiDependencies.outputs.aiServicesName
aiProjectPrincipalId: aiProject.outputs.aiProjectPrincipalId
aiProjectId: aiProject.outputs.aiProjectResourceId
}
}

module aiSearchRoleAssignments 'modules-standard-bing/ai-search-role-assignments-bing.bicep' = {
name: 'ai-search-role-assignments-${projectName}-${uniqueSuffix}-deployment'
scope: resourceGroup(aiSearchServiceSubscriptionId, aiSearchServiceResourceGroupName)
params: {
aiSearchName: aiDependencies.outputs.aiSearchName
aiProjectPrincipalId: aiProject.outputs.aiProjectPrincipalId
aiProjectId: aiProject.outputs.aiProjectResourceId
}
}

output PROJECT_CONNECTION_STRING string = aiProject.outputs.projectConnectionString
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#",
"type": "QuickStart",
"itemDisplayName": "Standard Agent Setup with Bing",
"description": "This set of templates demonstrates how to set up Azure AI Agent Service with the standard setup and bing, meaning with managed identity authentication and public internet access enabled. Agents use customer-owned, single-tenant search and storage resources. With this setup, you have full control and visibility over these resources, but you will incur costs based on your usage.",
"summary": "This set of templates demonstrates how to use Azure AI Agent Service with the standard setup and bing.",
"githubUsername": "fosteramanda",
"dateUpdated": "2024-12-06",
"environments": [
"AzureCloud"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Assigns the necessary roles to the AI project

@description('Name of the AI Search resource')
param aiSearchName string

@description('Principal ID of the AI project')
param aiProjectPrincipalId string

@description('Resource ID of the AI project')
param aiProjectId string

resource searchService 'Microsoft.Search/searchServices@2024-06-01-preview' existing = {
name: aiSearchName
scope: resourceGroup()
}

// search roles
resource searchIndexDataContributorRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: '8ebe5a00-799e-43f5-93ac-243d3dce84a7'
scope: resourceGroup()
}

resource searchIndexDataContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: searchService
name: guid(aiProjectId, searchIndexDataContributorRole.id, searchService.id)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: searchIndexDataContributorRole.id
principalType: 'ServicePrincipal'
}
}

resource searchServiceContributorRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: '7ca78c08-252a-4471-8644-bb5ff32d4ba0'
scope: resourceGroup()
}

resource searchServiceContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: searchService
name: guid(aiProjectId, searchServiceContributorRole.id, searchService.id)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: searchServiceContributorRole.id
principalType: 'ServicePrincipal'
}
}
Loading
Loading