Skip to content

Commit d8ff51c

Browse files
committed
Providing existing Azure OpenAI account with deployments for a new AI project
1 parent f7281a3 commit d8ff51c

3 files changed

Lines changed: 146 additions & 31 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"location": {
6+
"value": "eastus"
7+
},
8+
"ai_services": {
9+
"value": "aiServices"
10+
},
11+
"project_name": {
12+
"value": "project"
13+
},
14+
"existingAoaiResourceId": {
15+
"value": "/subscriptions/4d042dc6-fe17-4698-a23f-ec6a8d1e98f4/resourceGroups/vivazque-bsic-byo-aoi/providers/Microsoft.AI/aiServices/existing-aoai"
16+
}
17+
}
18+
}
Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
param accountName string = 'basicaccount${substring(uniqueString(utcNow()), 0,4)}'
2-
param projectName string = 'project'
1+
param account_name string = 'aiServices${substring(uniqueString(utcNow()), 0,4)}'
2+
param project_name string = 'project'
33
param projectDescription string = 'some description'
44
param projectDisplayName string = 'project_display_name'
5-
param location string = resourceGroup().location
5+
param location string
66

77
param modelName string = 'gpt-4o'
88
param modelFormat string = 'OpenAI'
99
param modelVersion string = '2024-11-20'
1010
param modelSkuName string = 'GlobalStandard'
1111
param modelCapacity int = 30
1212

13-
1413
#disable-next-line BCP081
15-
resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
16-
name: accountName
14+
resource account_name_resource 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
15+
name: account_name
1716
location: location
1817
sku: {
1918
name: 'S0'
@@ -24,14 +23,14 @@ resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
2423
}
2524
properties: {
2625
allowProjectManagement: true
27-
customSubDomainName: toLower(accountName)
26+
customSubDomainName: account_name
2827
networkAcls: {
2928
defaultAction: 'Allow'
3029
virtualNetworkRules: []
3130
ipRules: []
3231
}
3332
publicNetworkAccess: 'Enabled'
34-
disableLocalAuth: true
33+
disableLocalAuth: false
3534
}
3635
}
3736

@@ -41,29 +40,9 @@ resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
4140
- Agents will use the build-in model deployments
4241
*/
4342

44-
45-
46-
/*
47-
Step 3: Create a Cognitive Services Project
48-
49-
*/
50-
#disable-next-line BCP081
51-
resource project 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = {
52-
parent: account
53-
name: projectName
54-
location: location
55-
identity: {
56-
type: 'SystemAssigned'
57-
}
58-
properties: {
59-
description: projectDescription
60-
displayName: projectDisplayName
61-
}
62-
}
63-
6443
#disable-next-line BCP081
6544
resource modelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-10-01'= {
66-
parent: account
45+
parent: account_name_resource
6746
name: modelName
6847
sku : {
6948
capacity: modelCapacity
@@ -78,5 +57,23 @@ resource modelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-
7857
}
7958
}
8059

81-
output account_name string = account.name
82-
output project_name string = project.name
60+
/*
61+
Step 3: Create a Cognitive Services Project
62+
63+
*/
64+
resource account_name_project_name 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = {
65+
parent: account_name_resource
66+
name: '${project_name}'
67+
location: location
68+
identity: {
69+
type: 'SystemAssigned'
70+
}
71+
properties: {
72+
description: projectDescription
73+
displayName: projectDisplayName
74+
}
75+
}
76+
77+
output ENDPOINT string = account_name_resource.properties.endpoint
78+
output project_name string = account_name_project_name.name
79+
output account_name string = account_name_resource.name

0 commit comments

Comments
 (0)