Skip to content

Commit 1d0b33d

Browse files
feat: Replaced AVM modules with local modules to reduce the main.json file size
1 parent 5d561e9 commit 1d0b33d

File tree

27 files changed

+47145
-57884
lines changed

27 files changed

+47145
-57884
lines changed

infra/main.bicep

Lines changed: 82 additions & 395 deletions
Large diffs are not rendered by default.

infra/main.json

Lines changed: 41810 additions & 57437 deletions
Large diffs are not rendered by default.

infra/modules/app/machinelearning.bicep

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ param subnetResourceId string = ''
5353
param privateDnsZoneResourceIds array = []
5454

5555
// Use the AVM module for Machine Learning Workspace
56-
module workspace 'br/public:avm/res/machine-learning-services/workspace:0.3.0' = {
56+
module workspace '../machine-learning-services/workspace/main.bicep' = {
5757
name: 'avm-${workspaceName}-deployment'
5858
params: {
5959
// Required parameters
@@ -127,6 +127,42 @@ module workspace 'br/public:avm/res/machine-learning-services/workspace:0.3.0' =
127127
}
128128
]
129129
: []
130+
connections:[
131+
{
132+
name: 'openai_connection'
133+
category: 'AzureOpenAI'
134+
target: azureOpenAIEndpoint
135+
metadata: {
136+
apiType: 'azure'
137+
resourceId: azureOpenAIId
138+
}
139+
connectionProperties: {
140+
authType: 'ApiKey'
141+
credentials: {
142+
key: listKeys(azureOpenAIId, '2023-05-01').key1
143+
}
144+
}
145+
}
146+
{
147+
category: 'CognitiveSearch'
148+
target: azureAISearchEndpoint
149+
name: 'aisearch_connection'
150+
connectionProperties: {
151+
authType: 'ApiKey'
152+
credentials: {
153+
key: listAdminKeys(
154+
resourceId(
155+
subscription().subscriptionId,
156+
resourceGroup().name,
157+
'Microsoft.Search/searchServices',
158+
azureAISearchName
159+
),
160+
'2023-11-01'
161+
).primaryKey
162+
}
163+
}
164+
}
165+
]
130166
}
131167
}
132168

@@ -138,50 +174,6 @@ var azureOpenAIId = resourceId(
138174
azureOpenAIName
139175
)
140176

141-
// Create Azure OpenAI connection
142-
resource openai_connection 'Microsoft.MachineLearningServices/workspaces/connections@2024-01-01-preview' = {
143-
name: '${workspaceName}/openai_connection'
144-
properties: {
145-
authType: 'ApiKey'
146-
credentials: {
147-
key: listKeys(azureOpenAIId, '2023-05-01').key1
148-
}
149-
category: 'AzureOpenAI'
150-
target: azureOpenAIEndpoint
151-
metadata: {
152-
apiType: 'azure'
153-
resourceId: azureOpenAIId
154-
}
155-
}
156-
dependsOn: [
157-
workspace
158-
]
159-
}
160-
161-
// Create Azure AI Search connection if Azure AI Search is provided
162-
resource aisearch_connection 'Microsoft.MachineLearningServices/workspaces/connections@2024-01-01-preview' = if (azureAISearchName != '') {
163-
name: '${workspaceName}/aisearch_connection'
164-
properties: {
165-
authType: 'ApiKey'
166-
credentials: {
167-
key: listAdminKeys(
168-
resourceId(
169-
subscription().subscriptionId,
170-
resourceGroup().name,
171-
'Microsoft.Search/searchServices',
172-
azureAISearchName
173-
),
174-
'2023-11-01'
175-
).primaryKey
176-
}
177-
category: 'CognitiveSearch'
178-
target: azureAISearchEndpoint
179-
}
180-
dependsOn: [
181-
workspace
182-
]
183-
}
184-
185177
// Outputs to maintain compatibility with the previous implementation
186178
output workspaceName string = workspaceName
187179
output workspaceId string = workspace.outputs.resourceId
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
metadata name = 'Virtual Machine Extensions'
2+
metadata description = 'This module deploys a Virtual Machine Extension.'
3+
4+
@description('Conditional. The name of the parent virtual machine that extension is provisioned for. Required if the template is used in a standalone deployment.')
5+
param virtualMachineName string
6+
7+
@description('Required. The name of the virtual machine extension.')
8+
param name string
9+
10+
@description('Optional. The location the extension is deployed to.')
11+
param location string = resourceGroup().location
12+
13+
@description('Required. The name of the extension handler publisher.')
14+
param publisher string
15+
16+
@description('Required. Specifies the type of the extension; an example is "CustomScriptExtension".')
17+
param type string
18+
19+
@description('Required. Specifies the version of the script handler.')
20+
param typeHandlerVersion string
21+
22+
@description('Required. Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true.')
23+
param autoUpgradeMinorVersion bool
24+
25+
@description('Optional. How the extension handler should be forced to update even if the extension configuration has not changed.')
26+
param forceUpdateTag string = ''
27+
28+
@description('Optional. Any object that contains the extension specific settings.')
29+
param settings object = {}
30+
31+
@description('Optional. Any object that contains the extension specific protected settings.')
32+
@secure()
33+
param protectedSettings object = {}
34+
35+
@description('Optional. Indicates whether failures stemming from the extension will be suppressed (Operational failures such as not connecting to the VM will not be suppressed regardless of this value). The default is false.')
36+
param supressFailures bool = false
37+
38+
@description('Required. Indicates whether the extension should be automatically upgraded by the platform if there is a newer version of the extension available.')
39+
param enableAutomaticUpgrade bool
40+
41+
@description('Optional. Tags of the resource.')
42+
param tags object?
43+
44+
resource virtualMachine 'Microsoft.Compute/virtualMachines@2022-11-01' existing = {
45+
name: virtualMachineName
46+
}
47+
48+
resource extension 'Microsoft.Compute/virtualMachines/extensions@2022-11-01' = {
49+
name: name
50+
parent: virtualMachine
51+
location: location
52+
tags: tags
53+
properties: {
54+
publisher: publisher
55+
type: type
56+
typeHandlerVersion: typeHandlerVersion
57+
autoUpgradeMinorVersion: autoUpgradeMinorVersion
58+
enableAutomaticUpgrade: enableAutomaticUpgrade
59+
forceUpdateTag: !empty(forceUpdateTag) ? forceUpdateTag : null
60+
settings: !empty(settings) ? settings : null
61+
protectedSettings: !empty(protectedSettings) ? protectedSettings : null
62+
suppressFailures: supressFailures
63+
}
64+
}
65+
66+
@description('The name of the extension.')
67+
output name string = extension.name
68+
69+
@description('The resource ID of the extension.')
70+
output resourceId string = extension.id
71+
72+
@description('The name of the Resource Group the extension was created in.')
73+
output resourceGroupName string = resourceGroup().name
74+
75+
@description('The location the resource was deployed into.')
76+
output location string = extension.location

0 commit comments

Comments
 (0)