@@ -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
967967var 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
968974var aiFoundryAiServicesResourceName = useExistingAiFoundryAiProject
969975 ? split (existingAiFoundryAiProjectResourceId , '/' )[8 ]
970976 : 'aif-${solutionSuffix }'
@@ -985,14 +991,12 @@ var aiFoundryAiProjectDescription = 'AI Foundry Project'
985991
986992resource 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
994997module 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