Skip to content

Commit

Permalink
updating deploy files to support deploy using services with free tier…
Browse files Browse the repository at this point in the history
…, and OpenAI services
  • Loading branch information
elbruno committed Aug 29, 2024
1 parent 1fc0647 commit f546ab9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
21 changes: 16 additions & 5 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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 = ''

Expand Down Expand Up @@ -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')
Expand All @@ -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}'
Expand Down Expand Up @@ -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
Expand All @@ -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}'
}
}

Expand Down Expand Up @@ -490,7 +499,7 @@ module searchService 'core/search/search-services.bicep' = {
sku: {
name: searchServiceSkuName
}
semanticSearch: 'free'
semanticSearch: actualSearchServiceSemanticRankerLevel //semanticSearch: 'free'
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"value": "${AZURE_FORMRECOGNIZER_SERVICE}"
},
"formRecognizerSkuName": {
"value": "S0"
"value": "${AZURE_FORMRECOGNIZER_SERVICE_SKU=S0}"
},
"keyVaultName": {
"value": "${AZURE_KEY_VAULT_NAME}"
Expand Down Expand Up @@ -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}"
Expand All @@ -77,6 +80,9 @@
"useApplicationInsights": {
"value": "${AZURE_USE_APPLICATION_INSIGHTS=true}"
},
"publicNetworkAccess": {
"value": "${AZURE_PUBLIC_NETWORK_ACCESS=Enabled}"
},
"openAIApiKey": {
"value": "${OPENAI_API_KEY}"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/azd-env-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion scripts/azd-gh-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit f546ab9

Please sign in to comment.