Skip to content

Commit 072d611

Browse files
committed
Refactor AI Foundry AI Services module: streamline resource group and subscription ID assignment for existing AI projects
1 parent f3f30f7 commit 072d611

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

infra/main.bicep

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,12 @@ module avmPrivateDnsZones 'br/public:avm/res/network/private-dns-zone:0.7.1' = [
965965
// WAF best practices for Open AI: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/azure-openai
966966

967967
var useExistingAiFoundryAiProject = !empty(existingAiFoundryAiProjectResourceId)
968+
var aiFoundryAiServicesResourceGroupName = useExistingAiFoundryAiProject
969+
? split(existingAiFoundryAiProjectResourceId, '/')[4]
970+
: 'rg-${solutionSuffix}'
971+
var aiFoundryAiServicesSubscriptionId = useExistingAiFoundryAiProject
972+
? split(existingAiFoundryAiProjectResourceId, '/')[2]
973+
: subscription().id
968974
var aiFoundryAiServicesResourceName = useExistingAiFoundryAiProject
969975
? split(existingAiFoundryAiProjectResourceId, '/')[8]
970976
: 'aif-${solutionSuffix}'
@@ -985,14 +991,12 @@ var aiFoundryAiProjectDescription = 'AI Foundry Project'
985991

986992
resource existingAiFoundryAiServices 'Microsoft.CognitiveServices/accounts@2025-06-01' existing = if (useExistingAiFoundryAiProject) {
987993
name: aiFoundryAiServicesResourceName
988-
scope: resourceGroup(
989-
split(existingAiFoundryAiProjectResourceId, '/')[2],
990-
split(existingAiFoundryAiProjectResourceId, '/')[4]
991-
)
994+
scope: resourceGroup(aiFoundryAiServicesSubscriptionId, aiFoundryAiServicesResourceGroupName)
992995
}
993996

994997
module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.bicep' = if (useExistingAiFoundryAiProject) {
995998
name: take('module.ai-services-model-deployments.${existingAiFoundryAiServices.name}', 64)
999+
scope: resourceGroup(aiFoundryAiServicesSubscriptionId, aiFoundryAiServicesResourceGroupName)
9961000
params: {
9971001
name: existingAiFoundryAiServices.name
9981002
deployments: [

0 commit comments

Comments
 (0)