Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions infra/bicep/deploy_app_service.bicep
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// ========== Key Vault ========== //
targetScope = 'resourceGroup'

@description('Solution Location')
param solutionLocation string

@description('The pricing tier for the App Service plan')
@allowed(
['F1', 'D1', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3', 'P4','P0v3']
)
// param HostingPlanSku string = 'B1'

param HostingPlanSku string = 'B2'

param HostingPlanName string
Expand Down Expand Up @@ -170,7 +171,7 @@ var WebAppImageName = 'DOCKER|bycwacontainerreg.azurecr.io/byc-wa-app:${imageTag

resource HostingPlan 'Microsoft.Web/serverfarms@2020-06-01' = {
name: HostingPlanName
location: resourceGroup().location
location: solutionLocation
sku: {
name: HostingPlanSku
}
Expand All @@ -183,7 +184,7 @@ resource HostingPlan 'Microsoft.Web/serverfarms@2020-06-01' = {

resource Website 'Microsoft.Web/sites@2020-06-01' = {
name: WebsiteName
location: resourceGroup().location
location: solutionLocation
identity: {
type: 'SystemAssigned, UserAssigned'
userAssignedIdentities: {
Expand Down
25 changes: 18 additions & 7 deletions infra/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ param deploymentType string = 'GlobalStandard'
@allowed([
'gpt-4o-mini'
'gpt-4o'
'gpt-4'
])
param gptModelName string = 'gpt-4o-mini'

Expand All @@ -46,9 +45,20 @@ param embeddingModel string = 'text-embedding-ada-002'
@description('Capacity of the Embedding Model deployment')
param embeddingDeploymentCapacity int = 80

// @description('Fabric Workspace Id if you have one, else leave it empty. ')
// param fabricWorkspaceId string
param imageTag string = 'latest'

var uniqueId = toLower(uniqueString(environmentName, subscription().id, resourceGroup().location))
//restricting to these regions because assistants api for gpt-4o-mini is available only in these regions
@allowed(['australiaeast','eastus', 'eastus2','francecentral','japaneast','norwayeast','southindia', 'swedencentral','uksouth', 'westus', 'westus3'])
@description('Azure OpenAI Location')
param AzureOpenAILocation string = 'eastus2'

@description('Set this if you want to deploy to a different region than the resource group. Otherwise, it will use the resource group location by default.')
param AZURE_LOCATION string=''
var solutionLocation = empty(AZURE_LOCATION) ? resourceGroup().location : AZURE_LOCATION

var uniqueId = toLower(uniqueString(environmentName, subscription().id, solutionLocation))
var solutionPrefix = 'ca${padLeft(take(uniqueId, 12), 12, '0')}'

// Load the abbrevations file required to name the azure resources.
Expand All @@ -57,8 +67,8 @@ var abbrs = loadJsonContent('./abbreviations.json')
// var ApplicationInsightsName = '${abbrs.managementGovernance.applicationInsights}${solutionPrefix}-main'
// var WorkspaceName = '${abbrs.managementGovernance.logAnalyticsWorkspace}${solutionPrefix}-main'

var resourceGroupLocation = resourceGroup().location
var solutionLocation = resourceGroupLocation
//var resourceGroupLocation = resourceGroup().location
//var solutionLocation = resourceGroupLocation
// var baseUrl = 'https://raw.githubusercontent.com/microsoft/Build-your-own-copilot-Solution-Accelerator/main/'

var functionAppSqlPrompt ='''Generate a valid T-SQL query to find {query} for tables and columns provided below:
Expand Down Expand Up @@ -125,7 +135,7 @@ module aifoundry 'deploy_ai_foundry.bicep' = {
name: 'deploy_ai_foundry'
params: {
solutionName: solutionPrefix
solutionLocation: resourceGroupLocation
solutionLocation: AzureOpenAILocation
keyVaultName: keyvaultModule.outputs.keyvaultName
deploymentType: deploymentType
gptModelName: gptModelName
Expand Down Expand Up @@ -214,7 +224,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {

// resource Workspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
// name: WorkspaceName
// location: resourceGroup().location
// location: solutionLocation
// properties: {
// sku: {
// name: 'PerGB2018'
Expand All @@ -225,7 +235,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {

// resource ApplicationInsights 'Microsoft.Insights/components@2020-02-02' = {
// name: ApplicationInsightsName
// location: resourceGroup().location
// location: solutionLocation
// tags: {
// 'hidden-link:${resourceId('Microsoft.Web/sites',ApplicationInsightsName)}': 'Resource'
// }
Expand Down Expand Up @@ -277,6 +287,7 @@ module azureFunctionURL 'deploy_azure_function_script_url.bicep' = {
module appserviceModule 'deploy_app_service.bicep' = {
name: 'deploy_app_service'
params: {
solutionLocation: solutionLocation
HostingPlanName: '${abbrs.compute.appServicePlan}${solutionPrefix}'
WebsiteName: '${abbrs.compute.webApp}${solutionPrefix}'
AzureSearchService:aifoundry.outputs.aiSearchService
Expand Down
2 changes: 2 additions & 0 deletions infra/bicep/main.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o-min
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30'))

param embeddingDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_EMBEDDING_MODEL_CAPACITY', '80'))
param AzureOpenAILocation = readEnvironmentVariable('AZURE_ENV_OPENAI_LOCATION', 'eastus2')
param AZURE_LOCATION = readEnvironmentVariable('AZURE_ENV_LOCATION', '')
54 changes: 44 additions & 10 deletions infra/bicep/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "5725756876467977390"
"templateHash": "5995671308040328650"
}
},
"parameters": {
Expand Down Expand Up @@ -40,8 +40,7 @@
"defaultValue": "gpt-4o-mini",
"allowedValues": [
"gpt-4o-mini",
"gpt-4o",
"gpt-4"
"gpt-4o"
],
"minLength": 1,
"metadata": {
Expand Down Expand Up @@ -82,6 +81,33 @@
"imageTag": {
"type": "string",
"defaultValue": "latest"
},
"AzureOpenAILocation": {
"type": "string",
"defaultValue": "eastus2",
"allowedValues": [
"australiaeast",
"eastus",
"eastus2",
"francecentral",
"japaneast",
"norwayeast",
"southindia",
"swedencentral",
"uksouth",
"westus",
"westus3"
],
"metadata": {
"description": "Azure OpenAI Location"
}
},
"AZURE_LOCATION": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Set this if you want to deploy to a different region than the resource group. Otherwise, it will use the resource group location by default."
}
}
},
"variables": {
Expand Down Expand Up @@ -312,11 +338,10 @@
"virtualDesktopScalingPlan": "vdscaling-"
}
},
"uniqueId": "[toLower(uniqueString(parameters('environmentName'), subscription().id, resourceGroup().location))]",
"solutionLocation": "[if(empty(parameters('AZURE_LOCATION')), resourceGroup().location, parameters('AZURE_LOCATION'))]",
"uniqueId": "[toLower(uniqueString(parameters('environmentName'), subscription().id, variables('solutionLocation')))]",
"solutionPrefix": "[format('ca{0}', padLeft(take(variables('uniqueId'), 12), 12, '0'))]",
"abbrs": "[variables('$fxv#0')]",
"resourceGroupLocation": "[resourceGroup().location]",
"solutionLocation": "[variables('resourceGroupLocation')]",
"functionAppSqlPrompt": "Generate a valid T-SQL query to find {query} for tables and columns provided below:\r\n 1. Table: Clients\r\n Columns: ClientId, Client, Email, Occupation, MaritalStatus, Dependents\r\n 2. Table: InvestmentGoals\r\n Columns: ClientId, InvestmentGoal\r\n 3. Table: Assets\r\n Columns: ClientId, AssetDate, Investment, ROI, Revenue, AssetType\r\n 4. Table: ClientSummaries\r\n Columns: ClientId, ClientSummary\r\n 5. Table: InvestmentGoalsDetails\r\n Columns: ClientId, InvestmentGoal, TargetAmount, Contribution\r\n 6. Table: Retirement\r\n Columns: ClientId, StatusDate, RetirementGoalProgress, EducationGoalProgress\r\n 7. Table: ClientMeetings\r\n Columns: ClientId, ConversationId, Title, StartTime, EndTime, Advisor, ClientEmail\r\n Always use the Investment column from the Assets table as the value.\r\n Assets table has snapshots of values by date. Do not add numbers across different dates for total values.\r\n Do not use client name in filters.\r\n Do not include assets values unless asked for.\r\n ALWAYS use ClientId = {clientid} in the query filter.\r\n ALWAYS select Client Name (Column: Client) in the query.\r\n Query filters are IMPORTANT. Add filters like AssetType, AssetDate, etc. if needed.\r\n Only return the generated SQL query. Do not return anything else.",
"functionAppCallTranscriptSystemPrompt": "You are an assistant who supports wealth advisors in preparing for client meetings. \r\n You have access to the client’s past meeting call transcripts. \r\n When answering questions, especially summary requests, provide a detailed and structured response that includes key topics, concerns, decisions, and trends. \r\n If no data is available, state 'No relevant data found for previous meetings.",
"functionAppStreamTextSystemPrompt": "You are a helpful assistant to a Wealth Advisor. \r\n The currently selected client's name is '{SelectedClientName}', and any case-insensitive or partial mention should be understood as referring to this client.\r\n If no name is provided, assume the question is about '{SelectedClientName}'.\r\n If the query references a different client or includes comparative terms like 'compare' or 'other client', please respond with: 'Please only ask questions about the selected client or select another client.'\r\n Otherwise, provide thorough answers using only data from SQL or call transcripts. \r\n If no data is found, please respond with 'No data found for that client.' Remove any client identifiers from the final response."
Expand Down Expand Up @@ -671,7 +696,7 @@
"value": "[variables('solutionPrefix')]"
},
"solutionLocation": {
"value": "[variables('resourceGroupLocation')]"
"value": "[parameters('AzureOpenAILocation')]"
},
"keyVaultName": {
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_keyvault'), '2022-09-01').outputs.keyvaultName.value]"
Expand Down Expand Up @@ -2475,6 +2500,9 @@
},
"mode": "Incremental",
"parameters": {
"solutionLocation": {
"value": "[variables('solutionLocation')]"
},
"HostingPlanName": {
"value": "[format('{0}{1}', variables('abbrs').compute.appServicePlan, variables('solutionPrefix'))]"
},
Expand Down Expand Up @@ -2641,10 +2669,16 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "160171358527496715"
"templateHash": "2369588288479285540"
}
},
"parameters": {
"solutionLocation": {
"type": "string",
"metadata": {
"description": "Solution Location"
}
},
"HostingPlanSku": {
"type": "string",
"defaultValue": "B2",
Expand Down Expand Up @@ -2999,7 +3033,7 @@
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2020-06-01",
"name": "[parameters('HostingPlanName')]",
"location": "[resourceGroup().location]",
"location": "[parameters('solutionLocation')]",
"sku": {
"name": "[parameters('HostingPlanSku')]"
},
Expand All @@ -3013,7 +3047,7 @@
"type": "Microsoft.Web/sites",
"apiVersion": "2020-06-01",
"name": "[parameters('WebsiteName')]",
"location": "[resourceGroup().location]",
"location": "[parameters('solutionLocation')]",
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
Expand Down
2 changes: 1 addition & 1 deletion infra/scripts/process_sample_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fi

# Check if all required arguments are provided
if [ -z "$resourceGroupName" ] || [ -z "$cosmosDbAccountName" ] || [ -z "$storageAccount" ] || [ -z "$fileSystem" ] || [ -z "$keyvaultName" ] || [ -z "$sqlServerName" ] || [ -z "$SqlDatabaseName" ] || [ -z "$webAppManagedIdentityClientId" ] || [ -z "$webAppDisplayName" ] || [ -z "$functionAppManagedIdentityClientId" ] || [ -z "$functionAppDisplayName" ]; then
echo "Usage: $0 <resourceGroupName> <cosmosDbAccountName> <storageAccount> <fileSystem> <keyvaultName> <sqlServerName> <webAppManagedIdentityClientId> <webAppDisplayName> <functionAppManagedIdentityClientId> <functionAppDisplayName>"
echo "Usage: $0 <resourceGroupName> <cosmosDbAccountName> <storageAccount> <storageContainerName> <keyvaultName> <sqlServerName> <sqlDatabaseName> <webAppManagedIdentityClientId> <webAppDisplayName> <functionAppManagedIdentityClientId> <functionAppDisplayName>"
exit 1
fi

Expand Down