Skip to content

Commit fba0395

Browse files
Merge pull request #827 from microsoft/hb-psl-reduce-srch-time
refactor: replace avm module with bicep module for search service for initial provisioning
2 parents 6d3fe3e + 3b52504 commit fba0395

2 files changed

Lines changed: 56 additions & 2474 deletions

File tree

infra/main.bicep

Lines changed: 17 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
12881288
}
12891289
{
12901290
name: 'AZURE_AI_SEARCH_ENDPOINT'
1291-
value: searchService.outputs.endpoint
1291+
value: searchServiceUpdate.outputs.endpoint
12921292
}
12931293
{
12941294
name: 'AZURE_COGNITIVE_SERVICES'
@@ -1662,78 +1662,17 @@ var aiSearchIndexNameForRFPSummary = 'macae-rfp-summary-index'
16621662
var aiSearchIndexNameForRFPRisk = 'macae-rfp-risk-index'
16631663
var aiSearchIndexNameForRFPCompliance = 'macae-rfp-compliance-index'
16641664

1665-
module searchService 'br/public:avm/res/search/search-service:0.11.1' = {
1666-
name: take('avm.res.search.search-service.${solutionSuffix}', 64)
1667-
params: {
1668-
name: searchServiceName
1669-
authOptions: {
1670-
aadOrApiKey: {
1671-
aadAuthFailureMode: 'http401WithBearerChallenge'
1672-
}
1673-
}
1674-
disableLocalAuth: false
1675-
hostingMode: 'default'
1676-
1677-
// Enabled the Public access because other services are not able to connect with search search AVM module when public access is disabled
1678-
1679-
// publicNetworkAccess: enablePrivateNetworking ? 'Disabled' : 'Enabled'
1680-
publicNetworkAccess: 'Enabled'
1681-
networkRuleSet: {
1682-
bypass: 'AzureServices'
1683-
}
1684-
partitionCount: 1
1685-
replicaCount: 1
1686-
sku: enableScalability ? 'standard' : 'basic'
1687-
tags: tags
1688-
roleAssignments: [
1689-
{
1690-
principalId: userAssignedIdentity.outputs.principalId
1691-
roleDefinitionIdOrName: 'Search Index Data Contributor'
1692-
principalType: 'ServicePrincipal'
1693-
}
1694-
{
1695-
principalId: deployingUserPrincipalId
1696-
roleDefinitionIdOrName: 'Search Index Data Contributor'
1697-
principalType: deployerPrincipalType
1698-
}
1699-
{
1700-
principalId: aiFoundryAiProjectPrincipalId
1701-
roleDefinitionIdOrName: 'Search Index Data Reader'
1702-
principalType: 'ServicePrincipal'
1703-
}
1704-
{
1705-
principalId: aiFoundryAiProjectPrincipalId
1706-
roleDefinitionIdOrName: 'Search Service Contributor'
1707-
principalType: 'ServicePrincipal'
1708-
}
1709-
]
1710-
1711-
//Removing the Private endpoints as we are facing the issue with connecting to search service while comminicating with agents
1712-
1713-
privateEndpoints: []
1714-
// privateEndpoints: enablePrivateNetworking
1715-
// ? [
1716-
// {
1717-
// name: 'pep-search-${solutionSuffix}'
1718-
// customNetworkInterfaceName: 'nic-search-${solutionSuffix}'
1719-
// privateDnsZoneGroup: {
1720-
// privateDnsZoneGroupConfigs: [
1721-
// {
1722-
// privateDnsZoneResourceId: avmPrivateDnsZones[dnsZoneIndex.search]!.outputs.resourceId
1723-
// }
1724-
// ]
1725-
// }
1726-
// subnetResourceId: virtualNetwork!.outputs.subnetResourceIds[0]
1727-
// service: 'searchService'
1728-
// }
1729-
// ]
1730-
// : []
1665+
resource searchService 'Microsoft.Search/searchServices@2024-06-01-preview' = {
1666+
name: searchServiceName
1667+
location: location
1668+
sku: {
1669+
name: enableScalability ? 'standard' : 'basic'
17311670
}
17321671
}
17331672

1734-
// Separate module for Search Service to enable managed identity, as this reduces deployment time
1735-
module searchServiceIdentity 'br/public:avm/res/search/search-service:0.11.1' = {
1736-
name: take('avm.res.search.identity.${solutionSuffix}', 64)
1673+
// Separate module for Search Service to enable managed identity and update other properties, as this reduces deployment time
1674+
module searchServiceUpdate 'br/public:avm/res/search/search-service:0.11.1' = {
1675+
name: take('avm.res.search.update.${solutionSuffix}', 64)
17371676
params: {
17381677
name: searchServiceName
17391678
authOptions: {
@@ -1817,10 +1756,10 @@ module aiSearchFoundryConnection 'modules/aifp-connections.bicep' = {
18171756
aiFoundryProjectName: aiFoundryAiProjectName
18181757
aiFoundryName: aiFoundryAiServicesResourceName
18191758
aifSearchConnectionName: aiSearchConnectionName
1820-
searchServiceResourceId: searchService.outputs.resourceId
1821-
searchServiceLocation: searchService.outputs.location
1822-
searchServiceName: searchService.outputs.name
1823-
searchApiKey: searchService.outputs.primaryKey
1759+
searchServiceResourceId: searchService.id
1760+
searchServiceLocation: searchService.location
1761+
searchServiceName: searchService.name
1762+
searchApiKey: searchService.listAdminKeys().primaryKey
18241763
}
18251764
dependsOn: [
18261765
aiFoundryAiServices
@@ -1874,7 +1813,7 @@ module keyvault 'br/public:avm/res/key-vault/vault:0.12.1' = {
18741813
secrets: [
18751814
{
18761815
name: 'AzureAISearchAPIKey'
1877-
value: searchService.outputs.primaryKey
1816+
value: searchService.listAdminKeys().primaryKey
18781817
}
18791818
]
18801819
enableTelemetry: enableTelemetry
@@ -1893,8 +1832,8 @@ output webSiteDefaultHostname string = webSite.outputs.defaultHostname
18931832

18941833
output AZURE_STORAGE_BLOB_URL string = avmStorageAccount.outputs.serviceEndpoints.blob
18951834
output AZURE_STORAGE_ACCOUNT_NAME string = storageAccountName
1896-
output AZURE_AI_SEARCH_ENDPOINT string = searchService.outputs.endpoint
1897-
output AZURE_AI_SEARCH_NAME string = searchService.outputs.name
1835+
output AZURE_AI_SEARCH_ENDPOINT string = searchServiceUpdate.outputs.endpoint
1836+
output AZURE_AI_SEARCH_NAME string = searchService.name
18981837

18991838
output COSMOSDB_ENDPOINT string = 'https://${cosmosDbResourceName}.documents.azure.com:443/'
19001839
output COSMOSDB_DATABASE string = cosmosDbDatabaseName
@@ -1917,7 +1856,7 @@ output AI_FOUNDRY_RESOURCE_ID string = !useExistingAiFoundryAiProject
19171856
? aiFoundryAiServices.outputs.resourceId
19181857
: existingAiFoundryAiProjectResourceId
19191858
output COSMOSDB_ACCOUNT_NAME string = cosmosDbResourceName
1920-
output AZURE_SEARCH_ENDPOINT string = searchService.outputs.endpoint
1859+
output AZURE_SEARCH_ENDPOINT string = searchServiceUpdate.outputs.endpoint
19211860
output AZURE_CLIENT_ID string = userAssignedIdentity!.outputs.clientId
19221861
output AZURE_TENANT_ID string = tenant().tenantId
19231862
output AZURE_AI_SEARCH_CONNECTION_NAME string = aiSearchConnectionName

0 commit comments

Comments
 (0)