|
| 1 | +@description('') |
| 2 | +param azureDeployName string = utcNow() |
| 3 | +param account_name string = 'aiServices${substring(uniqueString(azureDeployName), 0,4)}' |
| 4 | +param project_name string = 'project' |
| 5 | +param projectDescription string = 'some description' |
| 6 | +param projectDisplayName string = 'project_display_name' |
| 7 | +param location string |
| 8 | + |
| 9 | +@description('The resource ID of the existing Azure OpenAI resource.') |
| 10 | +param existingAoaiResourceId string |
| 11 | + |
| 12 | +var byoAoaiConnectionName = 'aoaiConnection' |
| 13 | + |
| 14 | +// get subid, resource group name and resource name from the existing resource id |
| 15 | +var existingAoaiResourceIdParts = split(existingAoaiResourceId, '/') |
| 16 | +var existingAoaiResourceIdSubId = existingAoaiResourceIdParts[2] |
| 17 | +var existingAoaiResourceIdRgName = existingAoaiResourceIdParts[4] |
| 18 | +var existingAoaiResourceIdName = existingAoaiResourceIdParts[8] |
| 19 | + |
| 20 | +// define the existing Azure OpenAI resource |
| 21 | +resource existingAoaiResource 'Microsoft.CognitiveServices/accounts@2023-05-01' existing = { |
| 22 | + scope: resourceGroup(existingAoaiResourceIdSubId, existingAoaiResourceIdRgName) |
| 23 | + name: existingAoaiResourceIdName |
| 24 | +} |
| 25 | + |
| 26 | +resource account_name_resource 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = { |
| 27 | + #disable-next-line use-stable-resource-identifiers |
| 28 | + name: account_name |
| 29 | + location: location |
| 30 | + sku: { |
| 31 | + name: 'S0' |
| 32 | + } |
| 33 | + kind: 'AIServices' |
| 34 | + identity: { |
| 35 | + type: 'SystemAssigned' |
| 36 | + } |
| 37 | + properties: { |
| 38 | + allowProjectManagement: true |
| 39 | + customSubDomainName: account_name |
| 40 | + networkAcls: { |
| 41 | + defaultAction: 'Allow' |
| 42 | + virtualNetworkRules: [] |
| 43 | + ipRules: [] |
| 44 | + } |
| 45 | + publicNetworkAccess: 'Enabled' |
| 46 | + disableLocalAuth: false |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +resource account_name_project_name 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = { |
| 51 | + parent: account_name_resource |
| 52 | + name: project_name |
| 53 | + location: location |
| 54 | + identity: { |
| 55 | + type: 'SystemAssigned' |
| 56 | + } |
| 57 | + properties: { |
| 58 | + description: projectDescription |
| 59 | + displayName: projectDisplayName |
| 60 | + } |
| 61 | + |
| 62 | + resource byoAoaiConnection 'connections@2025-04-01-preview' = { |
| 63 | + name: byoAoaiConnectionName |
| 64 | + properties: { |
| 65 | + category: 'AzureOpenAI' |
| 66 | + target: existingAoaiResource.properties.endpoint |
| 67 | + authType: 'AAD' |
| 68 | + metadata: { |
| 69 | + ApiType: 'Azure' |
| 70 | + ResourceId: existingAoaiResource.id |
| 71 | + location: existingAoaiResource.location |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | + |
| 78 | +resource accountCapabilityHost 'Microsoft.CognitiveServices/accounts/capabilityHosts@2025-04-01-preview' = { |
| 79 | + name: '${account_name_resource.name}-capHost' |
| 80 | + parent: account_name_resource |
| 81 | + properties: { |
| 82 | + capabilityHostKind: 'Agents' |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +resource projectCapabilityHost 'Microsoft.CognitiveServices/accounts/projects/capabilityHosts@2025-04-01-preview' = { |
| 87 | + name: '${project_name}-capHost' |
| 88 | + parent: account_name_project_name |
| 89 | + properties: { |
| 90 | + capabilityHostKind: 'Agents' |
| 91 | + aiServicesConnections: [byoAoaiConnectionName] |
| 92 | + } |
| 93 | + dependsOn: [ |
| 94 | + accountCapabilityHost |
| 95 | + ] |
| 96 | +} |
| 97 | + |
| 98 | +output ENDPOINT string = account_name_resource.properties.endpoint |
| 99 | +output project_name string = account_name_project_name.name |
| 100 | +output account_name string = account_name_resource.name |
0 commit comments