From 5a6c79335ee8759a03b32deac7547fc18e6cd492 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Tue, 14 Oct 2025 14:29:00 +0530 Subject: [PATCH] added dns for existing project to access --- infra/main.bicep | 43 ++++++++++++++++++++++- infra/main.parameters.json | 2 +- infra/main.waf.parameters.json | 4 +-- infra/scripts/run_create_index_scripts.sh | 4 +-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/infra/main.bicep b/infra/main.bicep index 02afc9270..b18a9362b 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -535,7 +535,7 @@ var aiRelatedDnsZoneIndices = [ // =================================================== @batchSize(5) module avmPrivateDnsZones 'br/public:avm/res/network/private-dns-zone:0.7.1' = [ - for (zone, i) in privateDnsZones: if (enablePrivateNetworking && (empty(existingFoundryProjectResourceId) || !contains(aiRelatedDnsZoneIndices, i))) { + for (zone, i) in privateDnsZones: if (enablePrivateNetworking) { name: 'avm.res.network.private-dns-zone.${split(zone, '.')[1]}' params: { name: zone @@ -1165,6 +1165,47 @@ resource existingAiFoundryAiServicesProject 'Microsoft.CognitiveServices/account parent: existingAiFoundryAiServices } +// ========== Private Endpoint for Existing AI Services ========== // +var shouldCreatePrivateEndpoint = useExistingAiFoundryAiProject && enablePrivateNetworking +module existingAiServicesPrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.11.0' = if (shouldCreatePrivateEndpoint) { + name: take('module.private-endpoint.${existingAiFoundryAiServices.name}', 64) + params: { + name: 'pep-${existingAiFoundryAiServices.name}' + location: location + subnetResourceId: virtualNetwork!.outputs.pepsSubnetResourceId + customNetworkInterfaceName: 'nic-${existingAiFoundryAiServices.name}' + privateDnsZoneGroup: { + privateDnsZoneGroupConfigs: [ + { + name: 'ai-services-dns-zone-cognitiveservices' + privateDnsZoneResourceId: avmPrivateDnsZones[dnsZoneIndex.cognitiveServices]!.outputs.resourceId + } + { + name: 'ai-services-dns-zone-openai' + privateDnsZoneResourceId: avmPrivateDnsZones[dnsZoneIndex.openAI]!.outputs.resourceId + } + { + name: 'ai-services-dns-zone-aiservices' + privateDnsZoneResourceId: avmPrivateDnsZones[dnsZoneIndex.aiServices]!.outputs.resourceId + } + ] + } + privateLinkServiceConnections: [ + { + name: 'pep-${existingAiFoundryAiServices.name}' + properties: { + groupIds: ['account'] + privateLinkServiceId: existingAiFoundryAiServices.id + } + } + ] + tags: tags + } + dependsOn: [ + existingAiFoundryAiServices + avmPrivateDnsZones + ] +} var aiSearchName = 'srch-${solutionSuffix}' module searchService 'br/public:avm/res/search/search-service:0.11.1' = { diff --git a/infra/main.parameters.json b/infra/main.parameters.json index 092e5a315..bc3f7622f 100644 --- a/infra/main.parameters.json +++ b/infra/main.parameters.json @@ -17,7 +17,7 @@ "azureOpenaiAPIVersion": { "value": "${AZURE_ENV_MODEL_VERSION}" }, - "gptDeploymentCapacity": { + "gptModelCapacity": { "value": "${AZURE_ENV_MODEL_CAPACITY}" }, "embeddingModel": { diff --git a/infra/main.waf.parameters.json b/infra/main.waf.parameters.json index fcdb73193..291679d7a 100644 --- a/infra/main.waf.parameters.json +++ b/infra/main.waf.parameters.json @@ -8,7 +8,7 @@ "cosmosLocation": { "value": "${AZURE_ENV_COSMOS_LOCATION}" }, - "deploymentType": { + "gptModelDeploymentType": { "value": "${AZURE_ENV_MODEL_DEPLOYMENT_TYPE}" }, "gptModelName": { @@ -17,7 +17,7 @@ "azureOpenaiAPIVersion": { "value": "${AZURE_ENV_MODEL_VERSION}" }, - "gptDeploymentCapacity": { + "gptModelCapacity": { "value": "${AZURE_ENV_MODEL_CAPACITY}" }, "embeddingModel": { diff --git a/infra/scripts/run_create_index_scripts.sh b/infra/scripts/run_create_index_scripts.sh index ad4878d43..6a9c7d536 100644 --- a/infra/scripts/run_create_index_scripts.sh +++ b/infra/scripts/run_create_index_scripts.sh @@ -170,9 +170,9 @@ if [ -n "$managedIdentityClientId" ]; then fi # Determine the correct Python command -if command -v python3 &> /dev/null; then +if command -v python3 && python3 --version &> /dev/null; then PYTHON_CMD="python3" -elif command -v python &> /dev/null; then +elif command -v python && python --version &> /dev/null; then PYTHON_CMD="python" else echo "Python is not installed on this system. Or it is not added in the PATH."