Skip to content

Commit faa6c12

Browse files
author
Adrian Wright
committed
feat: use Foundry built into AI Services
1 parent b267696 commit faa6c12

File tree

2 files changed

+13
-137
lines changed

2 files changed

+13
-137
lines changed

voice_agent/app/infra/core/ai/ai-services.bicep

Lines changed: 12 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,12 @@ param cognitiveServicesAccountName string = foundryHubName
2222
@description('Name of the GPT-4o model deployment')
2323
param gpt4oDeploymentName string = 'gpt-4o'
2424

25-
@description('GPT-4o model name')
26-
param gpt4oModelName string = 'gpt-4o'
27-
28-
@description('GPT-4o model version')
29-
param gpt4oModelVersion string = '2024-05-13'
30-
3125
@description('Capacity for the GPT-4o model deployment')
3226
param gpt4oCapacity int = 1
3327

3428
@description('Name of the embedding model deployment')
3529
param embeddingModelDeploymentName string = 'text-embedding-ada-002'
3630

37-
@description('Embedding model version')
38-
param embeddingModelVersion string = '2'
39-
4031
@description('Name of the GPT-4o mini deployment')
4132
param gpt4oMiniModelDeploymentName string = 'gpt-4o-mini'
4233

@@ -64,9 +55,6 @@ param aiFoundryProjectName string = '${foundryHubName}-project'
6455
@description('Display name for the AI Foundry Project')
6556
param aiFoundryProjectDisplayName string = 'Voice Agent Multi Modal Workshop'
6657

67-
@description('API version for Azure OpenAI API')
68-
param apiVersion string = '2023-05-15'
69-
7058
@description('Abbreviations to use for resource naming')
7159
param abbrs object
7260

@@ -108,139 +96,43 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2019-04-01' = {
10896
tags: tags
10997
}
11098

111-
resource aiHub 'Microsoft.MachineLearningServices/workspaces@2024-07-01-preview' = {
112-
name: foundryHubName
99+
// Add Cognitive Services account of kind AIServices
100+
resource cognitiveServicesAccount 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
101+
name: cognitiveServicesAccountName
113102
location: location
114-
kind: 'hub'
103+
tags: tags
104+
kind: 'AIServices'
105+
sku: {
106+
name: accountSku
107+
}
115108
identity: {
116109
type: 'SystemAssigned'
117110
}
118111
properties: {
119-
description: 'Azure AI Foundry Hub'
120-
friendlyName: 'AI Foundry Hub'
112+
allowProjectManagement: true
121113
publicNetworkAccess: 'Enabled'
122-
storageAccount: storageAccount.id
123-
containerRegistry: containerRegistry.outputs.resourceId
124-
applicationInsights: applicationInsightsResourceId
125-
keyVault: keyVault.outputs.resourceId
126114
}
127-
tags: tags
128115
}
129116

130117
// Create the AI Foundry Project
131-
resource aiProject 'Microsoft.MachineLearningServices/workspaces@2024-07-01-preview' = {
118+
resource aiProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = {
119+
parent: cognitiveServicesAccount
132120
name: aiFoundryProjectName
133121
location: location
134-
kind: 'project'
135122
identity: {
136123
type: 'SystemAssigned'
137124
}
138125
properties: {
139-
description: 'AI Foundry Project for Video RAG'
140-
friendlyName: aiFoundryProjectDisplayName
141-
hubResourceId: aiHub.id
142-
publicNetworkAccess: 'Enabled'
126+
description: aiFoundryProjectDisplayName
143127
}
144128
tags: tags
145129
}
146130

147-
// Connect the Azure OpenAI endpoint to the AI Foundry Project
148-
resource aiServiceConnection 'Microsoft.MachineLearningServices/workspaces/connections@2023-08-01-preview' = {
149-
parent: aiProject
150-
name: '${foundryHubName}-ai-connection'
151-
properties: {
152-
category: 'AzureOpenAI'
153-
target: cognitiveServicesAccount.properties.endpoint
154-
authType: 'ApiKey'
155-
isSharedToAll: true
156-
credentials: {
157-
key: cognitiveServicesAccount.listKeys().key1
158-
}
159-
metadata: {
160-
resourceName: cognitiveServicesAccount.name
161-
ApiType: 'Azure'
162-
ApiVersion: apiVersion
163-
}
164-
}
165-
}
166-
167-
// Add Cognitive Services account of kind AIServices
168-
resource cognitiveServicesAccount 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
169-
name: cognitiveServicesAccountName
170-
location: location
171-
tags: tags
172-
kind: 'AIServices'
173-
sku: {
174-
name: accountSku
175-
}
176-
properties: {
177-
customSubDomainName: cognitiveServicesAccountName
178-
networkAcls: {
179-
defaultAction: 'Allow'
180-
}
181-
publicNetworkAccess: 'Enabled'
182-
}
183-
}
184-
185131
var contentUnderstandingEndpoint = 'https://${cognitiveServicesAccountName}.services.ai.azure.com/'
186132

187-
// User-assigned managed identity for the deployment script
188-
resource deploymentScriptIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
189-
name: 'id-deploymentscript-${resourceToken}'
190-
location: location
191-
tags: tags
192-
}
193-
194-
// Create role assignment for the deployment script identity to manage Cognitive Services
195-
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
196-
name: guid(resourceGroup().id, deploymentScriptIdentity.id, 'Contributor')
197-
scope: cognitiveServicesAccount
198-
properties: {
199-
principalId: deploymentScriptIdentity.properties.principalId
200-
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c') // Contributor role
201-
principalType: 'ServicePrincipal'
202-
}
203-
}
204-
205133
// Generate a unique token for resource naming
206134
var resourceToken = uniqueString(subscription().id, resourceGroup().id, cognitiveServicesAccountName)
207135

208-
209-
// resource chatModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2025-04-01-preview' = {
210-
// parent: cognitiveServicesAccount
211-
// name: gpt4oDeploymentName
212-
// sku: {
213-
// capacity: gpt4oCapacity
214-
// name: openAiSkuName
215-
// }
216-
// properties: {
217-
// model: {
218-
// format: openAiModelFormat
219-
// name: gpt4oModelName
220-
// version: gpt4oModelVersion
221-
// }
222-
// }
223-
// }
224-
225-
// resource embeddingModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2025-04-01-preview' = {
226-
// parent: cognitiveServicesAccount
227-
// name: embeddingModelDeploymentName
228-
// sku: {
229-
// capacity: gpt4oCapacity
230-
// name: openAiSkuName
231-
// }
232-
// properties: {
233-
// model: {
234-
// format: openAiModelFormat
235-
// name: embeddingModelDeploymentName
236-
// version: embeddingModelVersion
237-
// }
238-
// }
239-
// dependsOn: [
240-
// chatModelDeployment
241-
// ]
242-
// }
243-
244136
resource gpt4oMiniModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2025-04-01-preview' = {
245137
parent: cognitiveServicesAccount
246138
name: gpt4oMiniModelDeploymentName
@@ -295,12 +187,4 @@ output embeddingModelDeploymentName string = embeddingModelDeploymentName
295187
output gpt4oMiniModelDeploymentName string = gpt4oMiniModelDeploymentName
296188
output gpt4oMiniModelVersion string = gpt4oMiniModelVersion
297189
output realtimeModelDeploymentName string = realtimeModelDeploymentName
298-
output aiProjectName string = aiProject.name
299-
output aiProjectId string = aiProject.id
300-
output aiProjectPrincipalId string = aiProject.identity.principalId
301-
output aiServiceConnectionName string = aiServiceConnection.name
302-
output aiServiceConnectionId string = aiServiceConnection.id
303-
output resourceId string = aiHub.id
304-
output name string = aiHub.name
305-
output principalId string = aiHub.identity.principalId
306190
output containerRegistryName string = containerRegistry.outputs.name

voice_agent/app/infra/main.bicep

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ module aiServices './core/ai/ai-services.bicep' = {
198198
applicationInsightsResourceId: monitoring.outputs.applicationInsightsId
199199
cognitiveServicesAccountName: '${abbrs.cognitiveServicesAccounts}${resourceToken}'
200200
gpt4oDeploymentName: 'gpt-4o'
201-
gpt4oModelName: 'gpt-4o'
202-
gpt4oModelVersion: '2024-05-13'
203201
realtimeModelDeploymentName: 'gpt-4o-realtime-preview'
204202
embeddingModelDeploymentName: 'text-embedding-ada-002'
205203
gpt4oMiniModelDeploymentName: 'gpt-4o-mini'
@@ -376,7 +374,7 @@ module storageContribRoleApi 'core/security/role.bicep' = {
376374
}
377375

378376
module dataScientistRole 'core/security/subscription-role.bicep' = {
379-
name: 'data-scientist-role'
377+
name: 'data-scientist-role-${resourceToken}'
380378
params: {
381379
principalId: backendApp.outputs.SERVICE_BACKEND_PRINCIPAL_ID
382380
roleDefinitionId: 'f6c7c914-8db3-469d-8ca1-694a8f32e121' // Azure ML Data Scientist
@@ -391,12 +389,6 @@ output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registry
391389
output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.registryName
392390
output AZURE_CONTAINER_REGISTRY_RESOURCE_GROUP string = containerApps.outputs.registryName
393391
output AZURE_LOCATION string = location
394-
output AZURE_FOUNDRY_HUB_NAME string = aiServices.outputs.name
395-
output AZURE_FOUNDRY_HUB_ID string = aiServices.outputs.resourceId
396-
output AZURE_FOUNDRY_PROJECT_NAME string = aiServices.outputs.aiProjectName
397-
output AZURE_FOUNDRY_PROJECT_ID string = aiServices.outputs.aiProjectId
398-
output AZURE_AI_SERVICE_CONNECTION_NAME string = aiServices.outputs.aiServiceConnectionName
399-
output AZURE_AI_SERVICE_CONNECTION_ID string = aiServices.outputs.aiServiceConnectionId
400392
output AZURE_COGNITIVE_SERVICES_NAME string = aiServices.outputs.cognitiveServicesAccountName
401393
output AZURE_COGNITIVE_SERVICES_ID string = aiServices.outputs.cognitiveServicesAccountId
402394
output AZURE_COGNITIVE_SERVICES_ENDPOINT string = aiServices.outputs.cognitiveServicesEndpoint

0 commit comments

Comments
 (0)