Skip to content

Commit 74deb6e

Browse files
Merge pull request #381 from microsoft/dev-biceprefactoring
refactor: centralize Azure resource naming with abbreviations.json and update Bicep templates
2 parents dc1e22f + 9397700 commit 74deb6e

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

Deployment/main.bicep

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,55 @@
22
// Licensed under the MIT license.
33
@description('The Data Center where the model is deployed.')
44
param modeldatacenter string
5+
var abbrs = loadJsonContent('./abbreviations.json')
56

67
targetScope = 'subscription'
78
var resourceprefix = padLeft(take(uniqueString(deployment().name), 5), 5, '0')
89
var resourceprefix_name = 'kmgs'
910

1011
// Create a resource group
1112
resource gs_resourcegroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
12-
name: 'rg-${resourceprefix_name}${resourceprefix}'
13+
name: '${abbrs.managementGovernance.resourceGroup}${resourceprefix_name}${resourceprefix}'
1314
location: deployment().location
1415
}
1516

1617
// Create a storage account
1718
module gs_storageaccount 'bicep/azurestorageaccount.bicep' = {
18-
name: 'blob${resourceprefix_name}${resourceprefix}'
19+
name: '${abbrs.storage.storageAccount}${resourceprefix_name}${resourceprefix}'
1920
scope: gs_resourcegroup
2021
params: {
21-
storageAccountName: 'blob${resourceprefix}'
22+
storageAccountName: '${abbrs.storage.storageAccount}${resourceprefix}'
2223
location: deployment().location
2324
}
2425
}
2526

2627
// Create a Azure Search Service
2728
module gs_azsearch 'bicep/azuresearch.bicep' = {
28-
name: 'search-${resourceprefix_name}${resourceprefix}'
29+
name: '${abbrs.ai.aiSearch}${resourceprefix_name}${resourceprefix}'
2930
scope: gs_resourcegroup
3031
params: {
31-
searchServiceName: 'search-${resourceprefix}'
32+
searchServiceName: '${abbrs.ai.aiSearch}${resourceprefix}'
3233
location: deployment().location
3334
}
3435
}
3536

3637

3738
// Create Container Registry
3839
module gs_containerregistry 'bicep/azurecontainerregistry.bicep' = {
39-
name: 'acr${resourceprefix_name}${resourceprefix}'
40+
name: '${abbrs.containers.containerRegistry}${resourceprefix_name}${resourceprefix}'
4041
scope: gs_resourcegroup
4142
params: {
42-
acrName: 'acr${resourceprefix_name}${resourceprefix}'
43+
acrName: '${abbrs.containers.containerRegistry}${resourceprefix_name}${resourceprefix}'
4344
location: deployment().location
4445
}
4546
}
4647

4748
// Create AKS Cluster
4849
module gs_aks 'bicep/azurekubernetesservice.bicep' = {
49-
name: 'aks-${resourceprefix_name}${resourceprefix}'
50+
name: '${abbrs.compute.arcEnabledKubernetesCluster}${resourceprefix_name}${resourceprefix}'
5051
scope: gs_resourcegroup
5152
params: {
52-
aksName: 'aks-${resourceprefix_name}${resourceprefix}'
53+
aksName: '${abbrs.compute.arcEnabledKubernetesCluster}${resourceprefix_name}${resourceprefix}'
5354
location: deployment().location
5455
}
5556
dependsOn: [
@@ -74,20 +75,20 @@ module gs_aks 'bicep/azurekubernetesservice.bicep' = {
7475

7576
// Create Azure Cognitive Service
7677
module gs_azcognitiveservice 'bicep/azurecognitiveservice.bicep' = {
77-
name: 'cognitiveservice-${resourceprefix_name}${resourceprefix}'
78+
name: '${abbrs.ai.documentIntelligence}${resourceprefix_name}${resourceprefix}'
7879
scope: gs_resourcegroup
7980
params: {
80-
cognitiveServiceName: 'cognitiveservice-${resourceprefix_name}${resourceprefix}'
81+
cognitiveServiceName: '${abbrs.ai.documentIntelligence}${resourceprefix_name}${resourceprefix}'
8182
location: 'eastus'
8283
}
8384
}
8485

8586
// Create Azure Open AI Service
8687
module gs_openaiservice 'bicep/azureopenaiservice.bicep' = {
87-
name: 'openaiservice-${resourceprefix_name}${resourceprefix}'
88+
name: '${abbrs.ai.openAIService}${resourceprefix_name}${resourceprefix}'
8889
scope: gs_resourcegroup
8990
params: {
90-
openAIServiceName: 'openaiservice-${resourceprefix_name}${resourceprefix}'
91+
openAIServiceName: '${abbrs.ai.openAIService}${resourceprefix_name}${resourceprefix}'
9192
// GPT-4-32K model & GPT-4o available Data center information.
9293
// https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-4
9394
location: modeldatacenter
@@ -138,10 +139,10 @@ module gs_openaiservicemodels_text_embedding 'bicep/azureopenaiservicemodel.bice
138139

139140
// Create Azure Cosmos DB Mongo
140141
module gs_cosmosdb 'bicep/azurecosmosdb.bicep' = {
141-
name: 'cosmosdb-${resourceprefix_name}${resourceprefix}'
142+
name: '${abbrs.databases.cosmosDBDatabase}${resourceprefix_name}${resourceprefix}'
142143
scope: gs_resourcegroup
143144
params: {
144-
cosmosDbAccountName: 'cosmosdb-${resourceprefix_name}${resourceprefix}'
145+
cosmosDbAccountName: '${abbrs.databases.cosmosDBDatabase}${resourceprefix_name}${resourceprefix}'
145146
location: deployment().location
146147
}
147148
}
@@ -157,7 +158,7 @@ module gs_appconfig 'bicep/azureappconfigservice.bicep' = {
157158
}
158159

159160
// return all resource names as a output
160-
output gs_resourcegroup_name string = 'rg-${resourceprefix_name}${resourceprefix}'
161+
output gs_resourcegroup_name string = '${abbrs.managementGovernance.resourceGroup}${resourceprefix_name}${resourceprefix}'
161162
output gs_solution_prefix string = '${resourceprefix_name}${resourceprefix}'
162163
output gs_storageaccount_name string = gs_storageaccount.outputs.storageAccountName
163164
output gs_azsearch_name string = gs_azsearch.outputs.searchServiceName

0 commit comments

Comments
 (0)