diff --git a/infra/main.bicep b/infra/main.bicep index 6f7886366..eacddeecf 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -11,7 +11,7 @@ param resourceToken string = toLower(uniqueString(subscription().id, environment param location string @description('Name of App Service plan') -param hostingPlanName string = '${environmentName}-hosting-plan-${resourceToken}' +param hostingPlanName string = 'hosting-plan-${resourceToken}' @description('The pricing tier for the App Service plan') @allowed([ @@ -34,7 +34,7 @@ param hostingPlanSku string = 'B3' param websiteName string = 'web-${resourceToken}' @description('Name of Application Insights') -param applicationInsightsName string = '${environmentName}-appinsights-${resourceToken}' +param applicationInsightsName string = 'appinsights-${resourceToken}' @description('Use semantic search') param azureSearchUseSemanticSearch string = 'false' @@ -64,7 +64,7 @@ param azureSearchTitleColumn string = 'title' param azureSearchUrlColumn string = 'url' @description('Name of Azure OpenAI Resource') -param azureOpenAIResourceName string = '${environmentName}-openai-${resourceToken}' +param azureOpenAIResourceName string = 'openai-${resourceToken}' @description('Name of Azure OpenAI Resource SKU') param azureOpenAISkuName string = 'S0' @@ -112,7 +112,7 @@ param azureOpenAIEmbeddingModel string = 'text-embedding-ada-002' param azureOpenAIEmbeddingModelName string = 'text-embedding-ada-002' @description('Azure AI Search Resource') -param azureAISearchName string = '${environmentName}-search-${resourceToken}' +param azureAISearchName string = 'search-${resourceToken}' @description('The SKU of the search service you want to create. E.g. free or standard') @allowed([ @@ -125,7 +125,7 @@ param azureAISearchName string = '${environmentName}-search-${resourceToken}' param azureSearchSku string = 'standard' @description('Azure AI Search Index') -param azureSearchIndex string = '${environmentName}-index-${resourceToken}' +param azureSearchIndex string = 'index-${resourceToken}' @description('Azure AI Search Conversation Log Index') param azureSearchConversationLogIndex string = 'conversations' @@ -137,13 +137,13 @@ param storageAccountName string = 'str${resourceToken}' param functionName string = 'backend-${resourceToken}' @description('Azure Form Recognizer Name') -param formRecognizerName string = '${environmentName}-formrecog-${resourceToken}' +param formRecognizerName string = 'formrecog-${resourceToken}' @description('Azure Content Safety Name') -param contentSafetyName string = '${environmentName}-contentsafety-${resourceToken}' +param contentSafetyName string = 'contentsafety-${resourceToken}' @description('Azure Speech Service Name') -param speechServiceName string = '${environmentName}-speechservice-${resourceToken}' +param speechServiceName string = 'speech-${resourceToken}' param newGuidString string = newGuid() param searchTag string = 'chatwithyourdata-sa' diff --git a/infra/main.bicepparam b/infra/main.bicepparam index 93b8adde5..fcba60173 100644 --- a/infra/main.bicepparam +++ b/infra/main.bicepparam @@ -11,4 +11,25 @@ param useKeyVault = bool(readEnvironmentVariable('USE_KEY_VAULT', 'true')) param authType = readEnvironmentVariable('AZURE_AUTH_TYPE', 'keys') -param hostingModel = readEnvironmentVariable('AZURE_APP_SERVICE_HOSTING_MODEL', 'container') +param hostingModel = readEnvironmentVariable('AZURE_APP_SERVICE_HOSTING_MODEL', 'code') + +// The following are being renamed to align with the new naming convention +// we manipulate existing resources here to maintain backwards compatibility + +// We need the resourceToken to be unique for each deployment (copied from the main.bicep) +var subscriptionId = readEnvironmentVariable('AZURE_SUBSCRIPTION_ID', 'subscription_id') +param resourceToken = toLower(uniqueString(subscriptionId, environmentName, location)) + +// Retrieve the Search Name from the Search Endpoint which will be in the format +// "https://uniquename.search.windows.net/" It will end in a slash. Bicep forces us to have a default, so we use +// a default that we can manipulate in the same way to reduce another condition. +// length(azureAISearchEndpoint) - 9) cuts the https:// and the trailing slash. We then take the first "part" of +// the split which will be '' if there is no value set. If its null we assume the user is creating a new search +// service. +var azureAISearchEndpoint = readEnvironmentVariable('AZURE_SEARCH_SERVICE', 'https://./') +var searchServiceName = split(substring(azureAISearchEndpoint, 8, length(azureAISearchEndpoint) - 9), '.')[0] +param azureAISearchName = searchServiceName == '' ? 'search-${resourceToken}' : searchServiceName + +param azureSearchIndex = readEnvironmentVariable('AZURE_SEARCH_INDEX', 'index-${resourceToken}') +param azureOpenAIResourceName = readEnvironmentVariable('AZURE_OPENAI_RESOURCE', 'openai-${resourceToken}') + diff --git a/infra/main.json b/infra/main.json index b3e5979e8..65d7fd7e4 100644 --- a/infra/main.json +++ b/infra/main.json @@ -5,7 +5,7 @@ "_generator": { "name": "bicep", "version": "0.26.54.24096", - "templateHash": "13425064420748264745" + "templateHash": "15896839495287086142" } }, "parameters": { @@ -29,7 +29,7 @@ }, "hostingPlanName": { "type": "string", - "defaultValue": "[format('{0}-hosting-plan-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('hosting-plan-{0}', parameters('resourceToken'))]", "metadata": { "description": "Name of App Service plan" } @@ -64,7 +64,7 @@ }, "applicationInsightsName": { "type": "string", - "defaultValue": "[format('{0}-appinsights-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('appinsights-{0}', parameters('resourceToken'))]", "metadata": { "description": "Name of Application Insights" } @@ -134,7 +134,7 @@ }, "azureOpenAIResourceName": { "type": "string", - "defaultValue": "[format('{0}-openai-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('openai-{0}', parameters('resourceToken'))]", "metadata": { "description": "Name of Azure OpenAI Resource" } @@ -240,7 +240,7 @@ }, "azureAISearchName": { "type": "string", - "defaultValue": "[format('{0}-search-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('search-{0}', parameters('resourceToken'))]", "metadata": { "description": "Azure AI Search Resource" } @@ -261,7 +261,7 @@ }, "azureSearchIndex": { "type": "string", - "defaultValue": "[format('{0}-index-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('index-{0}', parameters('resourceToken'))]", "metadata": { "description": "Azure AI Search Index" } @@ -289,21 +289,21 @@ }, "formRecognizerName": { "type": "string", - "defaultValue": "[format('{0}-formrecog-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('formrecog-{0}', parameters('resourceToken'))]", "metadata": { "description": "Azure Form Recognizer Name" } }, "contentSafetyName": { "type": "string", - "defaultValue": "[format('{0}-contentsafety-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('contentsafety-{0}', parameters('resourceToken'))]", "metadata": { "description": "Azure Content Safety Name" } }, "speechServiceName": { "type": "string", - "defaultValue": "[format('{0}-speechservice-{1}', parameters('environmentName'), parameters('resourceToken'))]", + "defaultValue": "[format('speech-{0}', parameters('resourceToken'))]", "metadata": { "description": "Azure Speech Service Name" }