From f546ab97f2aa704fe26c18f54746823e2304dd3b Mon Sep 17 00:00:00 2001 From: Bruno Capuano Date: Thu, 29 Aug 2024 17:21:35 -0400 Subject: [PATCH] updating deploy files to support deploy using services with free tier, and OpenAI services --- .github/workflows/azure-dev.yml | 2 ++ infra/main.bicep | 21 ++++++++++++++++----- infra/main.parameters.json | 10 ++++++++-- scripts/azd-env-copy.sh | 2 +- scripts/azd-gh-vars.sh | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/azure-dev.yml b/.github/workflows/azure-dev.yml index 4fd01d4f..9404fe6f 100644 --- a/.github/workflows/azure-dev.yml +++ b/.github/workflows/azure-dev.yml @@ -23,12 +23,14 @@ env: AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }} AZURE_DEV_USER_AGENT: ${{ secrets.AZURE_DEV_USER_AGENT }} # Existing resources, when applicable + AZURE_APP_SERVICE_SKU: ${{ vars.azureAppServicePlanSku }} AZURE_OPENAI_SERVICE: ${{ vars.AZURE_OPENAI_SERVICE }} AZURE_OPENAI_RESOURCE_GROUP: ${{ vars.AZURE_OPENAI_RESOURCE_GROUP }} AZURE_FORMRECOGNIZER_SERVICE: ${{ vars.AZURE_FORMRECOGNIZER_SERVICE }} AZURE_FORMRECOGNIZER_RESOURCE_GROUP: ${{ vars.AZURE_FORMRECOGNIZER_RESOURCE_GROUP }} AZURE_SEARCH_SERVICE: ${{ vars.AZURE_SEARCH_SERVICE }} AZURE_SEARCH_SERVICE_RESOURCE_GROUP: ${{ vars.AZURE_SEARCH_SERVICE_RESOURCE_GROUP }} + AZURE_SEARCH_SERVICE_SKU: ${{ vars.AZURE_SEARCH_SERVICE_SKU }} AZURE_STORAGE_ACCOUNT: ${{ vars.AZURE_STORAGE_ACCOUNT }} AZURE_STORAGE_RESOURCE_GROUP: ${{ vars.AZURE_STORAGE_RESOURCE_GROUP }} AZURE_KEY_VAULT_NAME: ${{ vars.AZURE_KEY_VAULT_NAME }} diff --git a/infra/main.bicep b/infra/main.bicep index 11fb37bc..3cee9677 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -27,7 +27,10 @@ param azureOpenAIChatGptModelName string = 'gpt-4o-mini' @allowed([ '0613', '2024-07-18' ]) param azureOpenAIChatGptModelVersion string ='2024-07-18' -@description('Name of the Azure Application Insights dashboard') +@description('Defines if the process will deploy an Azure Application Insights resource') +param useApplicationInsights bool = true + +// @description('Name of the Azure Application Insights dashboard') param applicationInsightsDashboardName string = '' @description('Name of the Azure Application Insights resource') @@ -82,6 +85,7 @@ param formRecognizerResourceGroupName string = '' param formRecognizerServiceName string = '' @description('SKU name for the Form Recognizer service. Default: S0') +@allowed([ 'S0', 'F0' ]) param formRecognizerSkuName string = 'S0' @description('Name of the Azure Function App') @@ -129,9 +133,14 @@ param searchServiceResourceGroupLocation string = location @description('Name of the resource group for the Azure AI Search service') param searchServiceResourceGroupName string = '' +@description('Azure AI Search Semantic Ranker Level') +param searchServiceSemanticRankerLevel string // Set in main.parameters.json + @description('SKU name for the Azure AI Search service. Default: standard') param searchServiceSkuName string = 'standard' +var actualSearchServiceSemanticRankerLevel = (searchServiceSkuName == 'free') ? 'disabled' : searchServiceSemanticRankerLevel + @description('Name of the storage account') param storageAccountName string = '' @@ -168,7 +177,7 @@ param openAiChatGptDeployment string @description('OpenAI Embedding Model') param openAiEmbeddingDeployment string -@description('Use Vision retrival. default: false') +@description('Use Vision retrieval. default: false') param useVision bool = false var abbrs = loadJsonContent('./abbreviations.json') @@ -177,7 +186,6 @@ var resourceToken = toLower(uniqueString(subscription().id, environmentName, loc var baseTags = { 'azd-env-name': environmentName } var updatedTags = union(empty(tags) ? {} : base64ToJson(tags), baseTags) - // Organize resources in a resource group resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}' @@ -366,6 +374,7 @@ module function './app/function.bicep' = { AZURE_FORMRECOGNIZER_SERVICE_ENDPOINT: formRecognizer.outputs.endpoint AZURE_SEARCH_SERVICE_ENDPOINT: searchService.outputs.endpoint AZURE_SEARCH_INDEX: searchIndexName + AZURE_SEARCH_SEMANTIC_RANKER: actualSearchServiceSemanticRankerLevel AZURE_STORAGE_BLOB_ENDPOINT: storage.outputs.primaryEndpoints.blob AZURE_OPENAI_EMBEDDING_DEPLOYMENT: useAOAI ? azureEmbeddingDeploymentName : '' OPENAI_EMBEDDING_DEPLOYMENT: useAOAI ? '' : openAiEmbeddingDeployment @@ -388,7 +397,7 @@ module monitoring 'core/monitor/monitoring.bicep' = { includeApplicationInsights: true logAnalyticsName: !empty(logAnalyticsName) ? logAnalyticsName : '${abbrs.operationalInsightsWorkspaces}${resourceToken}' applicationInsightsName: !empty(applicationInsightsName) ? applicationInsightsName : '${abbrs.insightsComponents}${resourceToken}' - applicationInsightsDashboardName: !empty(applicationInsightsDashboardName) ? applicationInsightsDashboardName : '${abbrs.portalDashboards}${resourceToken}' + applicationInsightsDashboardName: !empty(applicationInsightsDashboardName) ? applicationInsightsDashboardName : '${abbrs.portalDashboards}${resourceToken}' } } @@ -490,7 +499,7 @@ module searchService 'core/search/search-services.bicep' = { sku: { name: searchServiceSkuName } - semanticSearch: 'free' + semanticSearch: actualSearchServiceSemanticRankerLevel //semanticSearch: 'free' } } @@ -733,6 +742,7 @@ module visionRoleBackend 'core/security/role.bicep' = if (useVision) { output APPLICATIONINSIGHTS_CONNECTION_STRING string = monitoring.outputs.applicationInsightsConnectionString output APPLICATIONINSIGHTS_NAME string = monitoring.outputs.applicationInsightsName +output AZURE_USE_APPLICATION_INSIGHTS bool = useApplicationInsights output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.environmentName output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registryLoginServer output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.registryName @@ -758,6 +768,7 @@ output AZURE_SEARCH_INDEX string = searchIndexName output AZURE_SEARCH_SERVICE string = searchService.outputs.name output AZURE_SEARCH_SERVICE_ENDPOINT string = searchService.outputs.endpoint output AZURE_SEARCH_SERVICE_RESOURCE_GROUP string = searchServiceResourceGroup.name +output AZURE_SEARCH_SERVICE_SKU string = searchServiceSkuName output AZURE_STORAGE_ACCOUNT string = storage.outputs.name output AZURE_STORAGE_BLOB_ENDPOINT string = storage.outputs.primaryEndpoints.blob output AZURE_STORAGE_CONTAINER string = storageContainerName diff --git a/infra/main.parameters.json b/infra/main.parameters.json index bd0f437f..bdfbdebb 100644 --- a/infra/main.parameters.json +++ b/infra/main.parameters.json @@ -18,7 +18,7 @@ "value": "${AZURE_FORMRECOGNIZER_SERVICE}" }, "formRecognizerSkuName": { - "value": "S0" + "value": "${AZURE_FORMRECOGNIZER_SERVICE_SKU=S0}" }, "keyVaultName": { "value": "${AZURE_KEY_VAULT_NAME}" @@ -60,7 +60,10 @@ "value": "${AZURE_SEARCH_SERVICE_RESOURCE_GROUP}" }, "searchServiceSkuName": { - "value": "standard" + "value": "${AZURE_SEARCH_SERVICE_SKU=standard}" + }, + "searchServiceSemanticRankerLevel": { + "value": "${AZURE_SEARCH_SEMANTIC_RANKER=free}" }, "storageAccountName": { "value": "${AZURE_STORAGE_ACCOUNT}" @@ -77,6 +80,9 @@ "useApplicationInsights": { "value": "${AZURE_USE_APPLICATION_INSIGHTS=true}" }, + "publicNetworkAccess": { + "value": "${AZURE_PUBLIC_NETWORK_ACCESS=Enabled}" + }, "openAIApiKey": { "value": "${OPENAI_API_KEY}" }, diff --git a/scripts/azd-env-copy.sh b/scripts/azd-env-copy.sh index 15f06bf3..100b08bf 100755 --- a/scripts/azd-env-copy.sh +++ b/scripts/azd-env-copy.sh @@ -19,7 +19,7 @@ if [ ! -f ".azure/$SOURCE_ENV_NAME/.env" ]; then fi # Define the list of environment variables to be used -VAR_LIST="AZURE_OPENAI_SERVICE AZURE_OPENAI_RESOURCE_GROUP AZURE_FORMRECOGNIZER_SERVICE AZURE_FORMRECOGNIZER_RESOURCE_GROUP AZURE_SEARCH_SERVICE AZURE_SEARCH_SERVICE_RESOURCE_GROUP AZURE_STORAGE_ACCOUNT AZURE_STORAGE_RESOURCE_GROUP AZURE_KEY_VAULT_NAME AZURE_KEY_VAULT_RESOURCE_GROUP SERVICE_WEB_IDENTITY_NAME" +VAR_LIST="AZURE_OPENAI_SERVICE AZURE_OPENAI_RESOURCE_GROUP AZURE_FORMRECOGNIZER_SERVICE AZURE_FORMRECOGNIZER_RESOURCE_GROUP AZURE_SEARCH_SERVICE AZURE_SEARCH_SERVICE_RESOURCE_GROUP AZURE_SEARCH_SERVICE_SKU AZURE_STORAGE_ACCOUNT AZURE_STORAGE_RESOURCE_GROUP AZURE_KEY_VAULT_NAME AZURE_KEY_VAULT_RESOURCE_GROUP SERVICE_WEB_IDENTITY_NAME AZURE_APP_SERVICE_SKU" echo "Variables to copy: $VAR_LIST" diff --git a/scripts/azd-gh-vars.sh b/scripts/azd-gh-vars.sh index 798160ac..4a4f1171 100755 --- a/scripts/azd-gh-vars.sh +++ b/scripts/azd-gh-vars.sh @@ -21,7 +21,7 @@ if [ ! -f ".azure/$AZD_ENV_NAME/.env" ]; then fi # Define the list of environment variables to be used -VAR_LIST="AZURE_OPENAI_SERVICE AZURE_OPENAI_RESOURCE_GROUP AZURE_FORMRECOGNIZER_SERVICE AZURE_FORMRECOGNIZER_RESOURCE_GROUP AZURE_SEARCH_SERVICE AZURE_SEARCH_SERVICE_RESOURCE_GROUP AZURE_STORAGE_ACCOUNT AZURE_STORAGE_RESOURCE_GROUP AZURE_KEY_VAULT_NAME AZURE_KEY_VAULT_RESOURCE_GROUP SERVICE_WEB_IDENTITY_NAME" +VAR_LIST="AZURE_OPENAI_SERVICE AZURE_OPENAI_RESOURCE_GROUP AZURE_FORMRECOGNIZER_SERVICE AZURE_FORMRECOGNIZER_RESOURCE_GROUP AZURE_SEARCH_SERVICE AZURE_SEARCH_SERVICE_RESOURCE_GROUP AZURE_SEARCH_SERVICE_SKU AZURE_STORAGE_ACCOUNT AZURE_STORAGE_RESOURCE_GROUP AZURE_KEY_VAULT_NAME AZURE_KEY_VAULT_RESOURCE_GROUP SERVICE_WEB_IDENTITY_NAME AZURE_APP_SERVICE_SKU" echo "Variables to copy: $VAR_LIST"