|
| 1 | +targetScope = 'resourceGroup' |
| 2 | + |
| 3 | +@description('The region in which this architecture is deployed. Should match the region of the resource group.') |
| 4 | +@minLength(1) |
| 5 | +param location string = resourceGroup().location |
| 6 | + |
| 7 | +@description('This is the base name for each Azure resource name (6-8 chars)') |
| 8 | +@minLength(6) |
| 9 | +@maxLength(8) |
| 10 | +param baseName string |
| 11 | + |
| 12 | +@description('The name of the workload\'s existing Log Analytics workspace.') |
| 13 | +@minLength(4) |
| 14 | +param logAnalyticsWorkspaceName string |
| 15 | + |
| 16 | +@description('Your principal ID. Allows you to access the Azure AI Foundry portal for post-deployment verification of functionality.') |
| 17 | +@maxLength(36) |
| 18 | +@minLength(36) |
| 19 | +param aiFoundryPortalUserPrincipalId string |
| 20 | + |
| 21 | +var aiFoundryName = 'aif${baseName}' |
| 22 | + |
| 23 | +// ---- Existing resources ---- |
| 24 | + |
| 25 | +@description('Existing: Built-in Cognitive Services User role.') |
| 26 | +resource cognitiveServicesUserRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { |
| 27 | + name: 'a97b65f3-24c7-4388-baec-2e87135dc908' |
| 28 | + scope: subscription() |
| 29 | +} |
| 30 | + |
| 31 | +@description('Existing: Log sink for Azure Diagnostics.') |
| 32 | +resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2025-02-01' existing = { |
| 33 | + name: logAnalyticsWorkspaceName |
| 34 | +} |
| 35 | + |
| 36 | +// ---- New resources ---- |
| 37 | + |
| 38 | +@description('Deploy Azure AI Foundry (account) with Azure AI Agent service capability.') |
| 39 | +resource aiFoundry 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = { |
| 40 | + name: aiFoundryName |
| 41 | + location: location |
| 42 | + kind: 'AIServices' |
| 43 | + sku: { |
| 44 | + name: 'S0' |
| 45 | + } |
| 46 | + identity: { |
| 47 | + type: 'SystemAssigned' |
| 48 | + } |
| 49 | + properties: { |
| 50 | + customSubDomainName: aiFoundryName |
| 51 | + allowProjectManagement: true // Azure AI Foundry account |
| 52 | + disableLocalAuth: true |
| 53 | + networkAcls: { |
| 54 | + bypass: 'AzureServices' |
| 55 | + ipRules: [] |
| 56 | + defaultAction: 'Allow' |
| 57 | + virtualNetworkRules: [] |
| 58 | + } |
| 59 | + publicNetworkAccess: 'Enabled' |
| 60 | + } |
| 61 | + |
| 62 | + @description('Models are managed at the account level. Deploy the GPT model that will be used for the Azure AI Agent logic.') |
| 63 | + resource model 'deployments' = { |
| 64 | + name: 'agent-model' |
| 65 | + sku: { |
| 66 | + capacity: 50 |
| 67 | + name: 'GlobalStandard' |
| 68 | + } |
| 69 | + properties: { |
| 70 | + model: { |
| 71 | + format: 'OpenAI' |
| 72 | + name: 'gpt-4o' |
| 73 | + version: '2024-11-20' // Use a model version available in your region. |
| 74 | + } |
| 75 | + versionUpgradeOption: 'NoAutoUpgrade' // Production deployments should not auto-upgrade models. Testing compatibility is important. |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +// Role assignments |
| 81 | + |
| 82 | +@description('Assign yourself to have access to the Azure AI Foundry portal.') |
| 83 | +resource cognitiveServicesUser 'Microsoft.Authorization/roleAssignments@2022-04-01' = { |
| 84 | + name: guid(aiFoundry.id, cognitiveServicesUserRole.id, aiFoundryPortalUserPrincipalId) |
| 85 | + scope: aiFoundry |
| 86 | + properties: { |
| 87 | + roleDefinitionId: cognitiveServicesUserRole.id |
| 88 | + principalId: aiFoundryPortalUserPrincipalId |
| 89 | + principalType: 'User' |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +// Azure diagnostics |
| 94 | + |
| 95 | +@description('Enable logging on the Azure AI Foundry account.') |
| 96 | +resource azureDiagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { |
| 97 | + name: 'default' |
| 98 | + scope: aiFoundry |
| 99 | + properties: { |
| 100 | + workspaceId: logAnalyticsWorkspace.id |
| 101 | + logs: [ |
| 102 | + { |
| 103 | + category: 'Audit' |
| 104 | + enabled: true |
| 105 | + retentionPolicy: { |
| 106 | + enabled: false |
| 107 | + days: 0 |
| 108 | + } |
| 109 | + } |
| 110 | + { |
| 111 | + category: 'RequestResponse' |
| 112 | + enabled: true |
| 113 | + retentionPolicy: { |
| 114 | + enabled: false |
| 115 | + days: 0 |
| 116 | + } |
| 117 | + } |
| 118 | + { |
| 119 | + category: 'AzureOpenAIRequestUsage' |
| 120 | + enabled: true |
| 121 | + retentionPolicy: { |
| 122 | + enabled: false |
| 123 | + days: 0 |
| 124 | + } |
| 125 | + } |
| 126 | + { |
| 127 | + category: 'Trace' |
| 128 | + enabled: true |
| 129 | + retentionPolicy: { |
| 130 | + enabled: false |
| 131 | + days: 0 |
| 132 | + } |
| 133 | + } |
| 134 | + ] |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +// ---- Outputs ---- |
| 139 | + |
| 140 | +@description('The name of the Azure AI Foundry account.') |
| 141 | +output aiFoundryName string = aiFoundry.name |
0 commit comments