@@ -15,6 +15,9 @@ param environmentName string
1515})
1616param location string
1717
18+ @description ('Optional numeric suffix for resource names (e.g., 56093778). Auto-generated if not provided.' )
19+ param nameSuffix string = ''
20+
1821@description ('Id of the user or app to assign application roles' )
1922param principalId string = ''
2023
@@ -50,16 +53,22 @@ param appRegistrationScopeId string = '' // Set via 'azd env set APP_REGISTRAT
5053import * as regionSelector from './app/util/region-selector.bicep'
5154var abbrs = loadJsonContent ('./abbreviations.json' )
5255
53- var resourceToken = toLower (uniqueString (subscription ().id , environmentName , location ))
56+ // Auto-generate suffix if not provided
57+ var autoSuffix = toLower (take (uniqueString (subscription ().id , environmentName , location ), 8 ))
58+ var actualSuffix = !empty (nameSuffix ) ? nameSuffix : autoSuffix
59+
60+ // Base name for all resources
61+ var resourceToken = 'snippymcplab'
62+
5463var tags = { 'azd-env-name' : environmentName }
55- var functionAppName = !empty (apiServiceName ) ? apiServiceName : '${abbrs .webSitesFunctions }api-${resourceToken }'
64+ var functionAppName = !empty (apiServiceName ) ? apiServiceName : '${abbrs .webSitesFunctions }api-${resourceToken }-${ actualSuffix } '
5665var deploymentStorageContainerName = 'app-package-${take (functionAppName , 32 )}-${take (toLower (uniqueString (functionAppName , resourceToken )), 7 )}'
5766
58- var storageAccountActualName = !empty (storageAccountName ) ? storageAccountName : '${abbrs .storageStorageAccounts }${resourceToken }'
67+ var storageAccountActualName = !empty (storageAccountName ) ? storageAccountName : '${abbrs .storageStorageAccounts }${resourceToken }${ actualSuffix } '
5968
6069// Organize resources in a resource group
6170resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
62- name : !empty (resourceGroupName ) ? resourceGroupName : '${abbrs .resourcesResourceGroups }${environmentName }'
71+ name : !empty (resourceGroupName ) ? resourceGroupName : '${abbrs .resourcesResourceGroups }${environmentName }-${ resourceToken }-${ actualSuffix } '
6372 location : location
6473 tags : tags
6574}
@@ -71,7 +80,7 @@ module apiUserAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned
7180 params : {
7281 location : location
7382 tags : tags
74- name : !empty (apiUserAssignedIdentityName ) ? apiUserAssignedIdentityName : '${abbrs .managedIdentityUserAssignedIdentities }api-${resourceToken }'
83+ name : !empty (apiUserAssignedIdentityName ) ? apiUserAssignedIdentityName : '${abbrs .managedIdentityUserAssignedIdentities }api-${resourceToken }-${ actualSuffix } '
7584 }
7685}
7786
@@ -130,8 +139,8 @@ module monitoring 'app/monitoring.bicep' = {
130139 params : {
131140 location : location
132141 tags : tags
133- logAnalyticsName : !empty (logAnalyticsName ) ? logAnalyticsName : '${abbrs .operationalInsightsWorkspaces }${resourceToken }'
134- applicationInsightsName : !empty (applicationInsightsName ) ? applicationInsightsName : '${abbrs .insightsComponents }${resourceToken }'
142+ logAnalyticsName : !empty (logAnalyticsName ) ? logAnalyticsName : '${abbrs .operationalInsightsWorkspaces }${resourceToken }-${ actualSuffix } '
143+ applicationInsightsName : !empty (applicationInsightsName ) ? applicationInsightsName : '${abbrs .insightsComponents }${resourceToken }-${ actualSuffix } '
135144 }
136145}
137146
@@ -156,7 +165,7 @@ module openai './app/ai/cognitive-services.bicep' = {
156165 location : regionSelector .getAiServicesRegion (location , chatModelName , embeddingModelName )
157166 tags : tags
158167 chatModelName : chatModelName
159- aiServicesName : '${abbrs .cognitiveServicesAccounts }${resourceToken }'
168+ aiServicesName : '${abbrs .cognitiveServicesAccounts }${resourceToken }-${ actualSuffix } '
160169 embeddingModelName : embeddingModelName
161170 }
162171}
@@ -194,7 +203,7 @@ module cosmosDb './app/cosmos-db.bicep' = {
194203 params : {
195204 location : location
196205 tags : tags
197- accountName : '${abbrs .documentDBDatabaseAccounts }${resourceToken }'
206+ accountName : '${abbrs .documentDBDatabaseAccounts }${resourceToken }-${ actualSuffix } '
198207 databaseName : cosmosDatabaseName
199208 containerName : cosmosContainerName
200209 dataContributorIdentityIds : [
@@ -212,6 +221,7 @@ module api './app/api.bicep' = {
212221 location : regionSelector .getFlexConsumptionRegion (location )
213222 tags : tags
214223 resourceToken : resourceToken
224+ actualSuffix : actualSuffix
215225 applicationInsightsName : monitoring .outputs .applicationInsightsName
216226 storageAccountName : storage .outputs .name
217227 deploymentStorageContainerName : deploymentStorageContainerName
@@ -248,7 +258,7 @@ module apim './app/apim.bicep' = {
248258 name : 'apim'
249259 scope : rg
250260 params : {
251- name : !empty (apimServiceName ) ? apimServiceName : '${abbrs .apiManagementService }${resourceToken }'
261+ name : !empty (apimServiceName ) ? apimServiceName : '${abbrs .apiManagementService }${resourceToken }-${ actualSuffix } '
252262 location : location
253263 tags : tags
254264 publisherName : apimPublisherName
@@ -279,8 +289,8 @@ module dts './app/dts.bicep' = {
279289 scope : rg
280290 name : 'dtsResource'
281291 params : {
282- name : !empty (dtsName ) ? dtsName : '${abbrs .dts }${resourceToken }'
283- taskhubname : !empty (taskHubName ) ? taskHubName : '${abbrs .taskhub }${resourceToken }'
292+ name : !empty (dtsName ) ? dtsName : '${abbrs .dts }${resourceToken }-${ actualSuffix } '
293+ taskhubname : !empty (taskHubName ) ? taskHubName : '${abbrs .taskhub }${resourceToken }${ actualSuffix } '
284294 location : location
285295 tags : tags
286296 ipAllowlist : [
0 commit comments