Skip to content

Commit 44425e0

Browse files
feat: Added feature to use azure_location env variable for deployment with Fallback to resource group location and updated azure openai supported region (#495)
* added supported OpenAI location and solutionLocation parameter and update resource locations in Bicep files * Updated the error message in process_sample_data.sh --------- Co-authored-by: Roopan P M <[email protected]>
1 parent 138e006 commit 44425e0

File tree

5 files changed

+70
-22
lines changed

5 files changed

+70
-22
lines changed

infra/bicep/deploy_app_service.bicep

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// ========== Key Vault ========== //
22
targetScope = 'resourceGroup'
33

4+
@description('Solution Location')
5+
param solutionLocation string
6+
47
@description('The pricing tier for the App Service plan')
58
@allowed(
69
['F1', 'D1', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3', 'P4','P0v3']
710
)
8-
// param HostingPlanSku string = 'B1'
9-
1011
param HostingPlanSku string = 'B2'
1112

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

171172
resource HostingPlan 'Microsoft.Web/serverfarms@2020-06-01' = {
172173
name: HostingPlanName
173-
location: resourceGroup().location
174+
location: solutionLocation
174175
sku: {
175176
name: HostingPlanSku
176177
}
@@ -183,7 +184,7 @@ resource HostingPlan 'Microsoft.Web/serverfarms@2020-06-01' = {
183184

184185
resource Website 'Microsoft.Web/sites@2020-06-01' = {
185186
name: WebsiteName
186-
location: resourceGroup().location
187+
location: solutionLocation
187188
identity: {
188189
type: 'SystemAssigned, UserAssigned'
189190
userAssignedIdentities: {

infra/bicep/main.bicep

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ param deploymentType string = 'GlobalStandard'
2222
@allowed([
2323
'gpt-4o-mini'
2424
'gpt-4o'
25-
'gpt-4'
2625
])
2726
param gptModelName string = 'gpt-4o-mini'
2827

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

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

51-
var uniqueId = toLower(uniqueString(environmentName, subscription().id, resourceGroup().location))
52+
//restricting to these regions because assistants api for gpt-4o-mini is available only in these regions
53+
@allowed(['australiaeast','eastus', 'eastus2','francecentral','japaneast','norwayeast','southindia', 'swedencentral','uksouth', 'westus', 'westus3'])
54+
@description('Azure OpenAI Location')
55+
param AzureOpenAILocation string = 'eastus2'
56+
57+
@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.')
58+
param AZURE_LOCATION string=''
59+
var solutionLocation = empty(AZURE_LOCATION) ? resourceGroup().location : AZURE_LOCATION
60+
61+
var uniqueId = toLower(uniqueString(environmentName, subscription().id, solutionLocation))
5262
var solutionPrefix = 'ca${padLeft(take(uniqueId, 12), 12, '0')}'
5363

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

60-
var resourceGroupLocation = resourceGroup().location
61-
var solutionLocation = resourceGroupLocation
70+
//var resourceGroupLocation = resourceGroup().location
71+
//var solutionLocation = resourceGroupLocation
6272
// var baseUrl = 'https://raw.githubusercontent.com/microsoft/Build-your-own-copilot-Solution-Accelerator/main/'
6373

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

215225
// resource Workspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
216226
// name: WorkspaceName
217-
// location: resourceGroup().location
227+
// location: solutionLocation
218228
// properties: {
219229
// sku: {
220230
// name: 'PerGB2018'
@@ -225,7 +235,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
225235

226236
// resource ApplicationInsights 'Microsoft.Insights/components@2020-02-02' = {
227237
// name: ApplicationInsightsName
228-
// location: resourceGroup().location
238+
// location: solutionLocation
229239
// tags: {
230240
// 'hidden-link:${resourceId('Microsoft.Web/sites',ApplicationInsightsName)}': 'Resource'
231241
// }
@@ -277,6 +287,7 @@ module azureFunctionURL 'deploy_azure_function_script_url.bicep' = {
277287
module appserviceModule 'deploy_app_service.bicep' = {
278288
name: 'deploy_app_service'
279289
params: {
290+
solutionLocation: solutionLocation
280291
HostingPlanName: '${abbrs.compute.appServicePlan}${solutionPrefix}'
281292
WebsiteName: '${abbrs.compute.webApp}${solutionPrefix}'
282293
AzureSearchService:aifoundry.outputs.aiSearchService

infra/bicep/main.bicepparam

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o-min
77
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30'))
88

99
param embeddingDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_EMBEDDING_MODEL_CAPACITY', '80'))
10+
param AzureOpenAILocation = readEnvironmentVariable('AZURE_ENV_OPENAI_LOCATION', 'eastus2')
11+
param AZURE_LOCATION = readEnvironmentVariable('AZURE_ENV_LOCATION', '')

infra/bicep/main.json

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.34.44.8038",
8-
"templateHash": "5725756876467977390"
8+
"templateHash": "5995671308040328650"
99
}
1010
},
1111
"parameters": {
@@ -40,8 +40,7 @@
4040
"defaultValue": "gpt-4o-mini",
4141
"allowedValues": [
4242
"gpt-4o-mini",
43-
"gpt-4o",
44-
"gpt-4"
43+
"gpt-4o"
4544
],
4645
"minLength": 1,
4746
"metadata": {
@@ -82,6 +81,33 @@
8281
"imageTag": {
8382
"type": "string",
8483
"defaultValue": "latest"
84+
},
85+
"AzureOpenAILocation": {
86+
"type": "string",
87+
"defaultValue": "eastus2",
88+
"allowedValues": [
89+
"australiaeast",
90+
"eastus",
91+
"eastus2",
92+
"francecentral",
93+
"japaneast",
94+
"norwayeast",
95+
"southindia",
96+
"swedencentral",
97+
"uksouth",
98+
"westus",
99+
"westus3"
100+
],
101+
"metadata": {
102+
"description": "Azure OpenAI Location"
103+
}
104+
},
105+
"AZURE_LOCATION": {
106+
"type": "string",
107+
"defaultValue": "",
108+
"metadata": {
109+
"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."
110+
}
85111
}
86112
},
87113
"variables": {
@@ -312,11 +338,10 @@
312338
"virtualDesktopScalingPlan": "vdscaling-"
313339
}
314340
},
315-
"uniqueId": "[toLower(uniqueString(parameters('environmentName'), subscription().id, resourceGroup().location))]",
341+
"solutionLocation": "[if(empty(parameters('AZURE_LOCATION')), resourceGroup().location, parameters('AZURE_LOCATION'))]",
342+
"uniqueId": "[toLower(uniqueString(parameters('environmentName'), subscription().id, variables('solutionLocation')))]",
316343
"solutionPrefix": "[format('ca{0}', padLeft(take(variables('uniqueId'), 12), 12, '0'))]",
317344
"abbrs": "[variables('$fxv#0')]",
318-
"resourceGroupLocation": "[resourceGroup().location]",
319-
"solutionLocation": "[variables('resourceGroupLocation')]",
320345
"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.",
321346
"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.",
322347
"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."
@@ -671,7 +696,7 @@
671696
"value": "[variables('solutionPrefix')]"
672697
},
673698
"solutionLocation": {
674-
"value": "[variables('resourceGroupLocation')]"
699+
"value": "[parameters('AzureOpenAILocation')]"
675700
},
676701
"keyVaultName": {
677702
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_keyvault'), '2022-09-01').outputs.keyvaultName.value]"
@@ -2475,6 +2500,9 @@
24752500
},
24762501
"mode": "Incremental",
24772502
"parameters": {
2503+
"solutionLocation": {
2504+
"value": "[variables('solutionLocation')]"
2505+
},
24782506
"HostingPlanName": {
24792507
"value": "[format('{0}{1}', variables('abbrs').compute.appServicePlan, variables('solutionPrefix'))]"
24802508
},
@@ -2641,10 +2669,16 @@
26412669
"_generator": {
26422670
"name": "bicep",
26432671
"version": "0.34.44.8038",
2644-
"templateHash": "160171358527496715"
2672+
"templateHash": "2369588288479285540"
26452673
}
26462674
},
26472675
"parameters": {
2676+
"solutionLocation": {
2677+
"type": "string",
2678+
"metadata": {
2679+
"description": "Solution Location"
2680+
}
2681+
},
26482682
"HostingPlanSku": {
26492683
"type": "string",
26502684
"defaultValue": "B2",
@@ -2999,7 +3033,7 @@
29993033
"type": "Microsoft.Web/serverfarms",
30003034
"apiVersion": "2020-06-01",
30013035
"name": "[parameters('HostingPlanName')]",
3002-
"location": "[resourceGroup().location]",
3036+
"location": "[parameters('solutionLocation')]",
30033037
"sku": {
30043038
"name": "[parameters('HostingPlanSku')]"
30053039
},
@@ -3013,7 +3047,7 @@
30133047
"type": "Microsoft.Web/sites",
30143048
"apiVersion": "2020-06-01",
30153049
"name": "[parameters('WebsiteName')]",
3016-
"location": "[resourceGroup().location]",
3050+
"location": "[parameters('solutionLocation')]",
30173051
"identity": {
30183052
"type": "SystemAssigned, UserAssigned",
30193053
"userAssignedIdentities": {

infra/scripts/process_sample_data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fi
6161

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

0 commit comments

Comments
 (0)