Skip to content

Commit 6fe8692

Browse files
Added condition for Azure openAI and Azure Ai Project name selection based on existing and new deployment
1 parent 560a356 commit 6fe8692

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

infra/main.bicep

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,9 @@ module privateDnsZonesAiServices 'br/public:avm/res/network/private-dns-zone:0.7
697697
]
698698

699699
// NOTE: Required version 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' not available in AVM
700-
var aiFoundryAiServicesResourceName = aiFoundryAiServicesConfiguration.?name ?? 'aisa-${solutionPrefix}'
700+
var useExistingFoundryProject = !empty(existingFoundryProjectResourceId)
701+
var existingAiFounryName = useExistingFoundryProject?split( existingFoundryProjectResourceId,'/')[8]:''
702+
var aiFoundryAiServicesResourceName = useExistingFoundryProject? existingAiFounryName : aiFoundryAiServicesConfiguration.?name ?? 'aisa-${solutionPrefix}'
701703
var aiFoundryAIservicesEnabled = aiFoundryAiServicesConfiguration.?enabled ?? true
702704
var aiFoundryAiServicesModelDeployment = {
703705
format: 'OpenAI'
@@ -743,8 +745,8 @@ module aiFoundryAiServices 'modules/account/main.bicep' = if (aiFoundryAIservice
743745
privateEndpoints: virtualNetworkEnabled
744746
? ([
745747
{
746-
name: 'pep-${aiFoundryAiServicesResourceName}'
747-
customNetworkInterfaceName: 'nic-${aiFoundryAiServicesResourceName}'
748+
name: 'pep-${aiFoundryAiServicesConfiguration.?name ?? 'aisa-${solutionPrefix}'}'
749+
customNetworkInterfaceName: 'nic-${aiFoundryAiServicesConfiguration.?name ?? 'aisa-${solutionPrefix}'}'
748750
subnetResourceId: aiFoundryAiServicesConfiguration.?subnetResourceId ?? virtualNetwork.outputs.subnetResourceIds[0]
749751
privateDnsZoneGroup: {
750752
privateDnsZoneGroupConfigs: map(objectKeys(openAiPrivateDnsZones), zone => {
@@ -775,7 +777,8 @@ module aiFoundryAiServices 'modules/account/main.bicep' = if (aiFoundryAIservice
775777

776778
// AI Foundry: AI Project
777779
// WAF best practices for Open AI: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/azure-openai
778-
var aiFoundryAiProjectName = aiFoundryAiProjectConfiguration.?name ?? 'aifp-${solutionPrefix}'
780+
var existingAiFounryProjectName = useExistingFoundryProject?last(split( existingFoundryProjectResourceId,'/')): ''
781+
var aiFoundryAiProjectName = useExistingFoundryProject? existingAiFounryProjectName : aiFoundryAiProjectConfiguration.?name ?? 'aifp-${solutionPrefix}'
779782

780783
resource aiUser 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
781784
name: '53ca6127-db72-4b80-b1b0-d745d6d5456d'

0 commit comments

Comments
 (0)