Skip to content

Commit 33578aa

Browse files
Added foundry SDK changes
1 parent 7549ab3 commit 33578aa

8 files changed

Lines changed: 224 additions & 38 deletions

File tree

infra/deploy_ai_foundry.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,4 +500,4 @@ output applicationInsightsId string = applicationInsights.id
500500
output logAnalyticsWorkspaceResourceName string = useExisting ? existingLogAnalyticsWorkspace.name : logAnalytics.name
501501
output storageAccountName string = storageNameCleaned
502502
output applicationInsightsConnectionString string = applicationInsights.properties.ConnectionString
503-
503+
output azureProjectConnString string = '${split(aiHubProject.properties.discoveryUrl, '/')[2]};${subscription().subscriptionId};${resourceGroup().name};${aiHubProject.name}'

infra/deploy_app_service.bicep

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ param AzureOpenAIEndpoint string = ''
3939
@secure()
4040
param AzureOpenAIKey string
4141

42+
@description('Azure Open AI Project Connection String')
43+
param AzureOpenAIProjectConnString string
44+
45+
@description('Azure AI project name')
46+
param AzureAIProjectName string
47+
4248
param azureOpenAIApiVersion string
4349
param AZURE_OPENAI_RESOURCE string = ''
4450
param USE_CHAT_HISTORY_ENABLED string = ''
@@ -102,6 +108,9 @@ param AZURE_COSMOSDB_DATABASE string = ''
102108
@description('Enable feedback in Cosmos DB')
103109
param AZURE_COSMOSDB_ENABLE_FEEDBACK string = 'True'
104110

111+
@description('Use AI Foundry SDK')
112+
param useAiFoundrySdk string = 'False'
113+
105114
param imageTag string
106115
param applicationInsightsId string
107116

@@ -257,6 +266,10 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
257266
name: 'AZURE_OPENAI_SYSTEM_MESSAGE'
258267
value: azureOpenAISystemMessage
259268
}
269+
{
270+
name: 'AZURE_OPENAI_PROJECT_CONN_STRING'
271+
value: AzureOpenAIProjectConnString
272+
}
260273
{
261274
name: 'USE_CHAT_HISTORY_ENABLED'
262275
value: USE_CHAT_HISTORY_ENABLED
@@ -288,6 +301,10 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
288301
name: 'UWSGI_THREADS'
289302
value: '2'
290303
}
304+
{
305+
name: 'USE_AI_FOUNDRY_SDK'
306+
value: useAiFoundrySdk
307+
}
291308
]
292309
linuxFxVersion: imageName
293310
}
@@ -338,4 +355,22 @@ resource role 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-
338355
}
339356
}
340357

358+
resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' existing = {
359+
name: AzureAIProjectName
360+
}
361+
362+
resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
363+
name: '64702f94-c441-49e6-a78b-ef80e0188fee'
364+
}
365+
366+
resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
367+
name: guid(Website.name, aiHubProject.id, aiDeveloper.id)
368+
scope: aiHubProject
369+
properties: {
370+
roleDefinitionId: aiDeveloper.id
371+
principalId: Website.identity.principalId
372+
}
373+
}
374+
375+
341376
output webAppUrl string = 'https://${WebsiteName}.azurewebsites.net'

infra/main.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ module appserviceModule 'deploy_app_service.bicep' = {
389389
AzureOpenAIKey:keyVault.getSecret('AZURE-OPENAI-KEY')
390390
azureOpenAIApiVersion: azureOpenaiAPIVersion //'2024-02-15-preview'
391391
AZURE_OPENAI_RESOURCE:aifoundry.outputs.aiServicesName
392+
AzureOpenAIProjectConnString:aifoundry.outputs.azureProjectConnString
393+
AzureAIProjectName: aifoundry.outputs.aiProjectName
392394
USE_CHAT_HISTORY_ENABLED:'True'
393395
AZURE_COSMOSDB_ACCOUNT: cosmosDBModule.outputs.cosmosAccountName
394396
// AZURE_COSMOSDB_ACCOUNT_KEY: keyVault.getSecret('AZURE-COSMOSDB-ACCOUNT-KEY')
@@ -398,6 +400,7 @@ module appserviceModule 'deploy_app_service.bicep' = {
398400
AZURE_COSMOSDB_ENABLE_FEEDBACK:'True'
399401
HostingPlanName:'${abbrs.compute.appServicePlan}${solutionPrefix}'
400402
WebsiteName:'${abbrs.compute.webApp}${solutionPrefix}'
403+
useAiFoundrySdk: 'False'
401404
}
402405
scope: resourceGroup(resourceGroup().name)
403406
// dependsOn:[sqlDBModule]

infra/main.json

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@
361361
"metadata": {
362362
"_generator": {
363363
"name": "bicep",
364-
"version": "0.35.1.17967",
365-
"templateHash": "14416829741819681429"
364+
"version": "0.34.44.8038",
365+
"templateHash": "17718433303911294858"
366366
}
367367
},
368368
"parameters": {
@@ -456,8 +456,8 @@
456456
"metadata": {
457457
"_generator": {
458458
"name": "bicep",
459-
"version": "0.35.1.17967",
460-
"templateHash": "14711167186840027914"
459+
"version": "0.34.44.8038",
460+
"templateHash": "10936025922757970234"
461461
}
462462
},
463463
"parameters": {
@@ -888,6 +888,7 @@
888888
"aiSearchName": "[format('{0}{1}', variables('abbrs').ai.aiSearch, parameters('solutionName'))]",
889889
"workspaceName": "[format('{0}{1}', variables('abbrs').managementGovernance.logAnalyticsWorkspace, parameters('solutionName'))]",
890890
"useExisting": "[not(empty(parameters('existingLogAnalyticsWorkspaceId')))]",
891+
"existingLawSubscription": "[if(variables('useExisting'), split(parameters('existingLogAnalyticsWorkspaceId'), '/')[2], '')]",
891892
"existingLawResourceGroup": "[if(variables('useExisting'), split(parameters('existingLogAnalyticsWorkspaceId'), '/')[4], '')]",
892893
"existingLawName": "[if(variables('useExisting'), split(parameters('existingLogAnalyticsWorkspaceId'), '/')[8], '')]",
893894
"aiModelDeployments": [
@@ -989,7 +990,7 @@
989990
"Application_Type": "web",
990991
"publicNetworkAccessForIngestion": "Enabled",
991992
"publicNetworkAccessForQuery": "Enabled",
992-
"WorkspaceResourceId": "[if(variables('useExisting'), extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, variables('existingLawResourceGroup')), 'Microsoft.OperationalInsights/workspaces', variables('existingLawName')), resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName')))]"
993+
"WorkspaceResourceId": "[if(variables('useExisting'), extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', variables('existingLawSubscription'), variables('existingLawResourceGroup')), 'Microsoft.OperationalInsights/workspaces', variables('existingLawName')), resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName')))]"
993994
},
994995
"dependsOn": [
995996
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName'))]"
@@ -1406,6 +1407,10 @@
14061407
"applicationInsightsConnectionString": {
14071408
"type": "string",
14081409
"value": "[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2020-02-02').ConnectionString]"
1410+
},
1411+
"azureProjectConnString": {
1412+
"type": "string",
1413+
"value": "[format('{0};{1};{2};{3}', split(reference(resourceId('Microsoft.MachineLearningServices/workspaces', variables('aiProjectName')), '2024-01-01-preview').discoveryUrl, '/')[2], subscription().subscriptionId, resourceGroup().name, variables('aiProjectName'))]"
14091414
}
14101415
}
14111416
}
@@ -1448,8 +1453,8 @@
14481453
"metadata": {
14491454
"_generator": {
14501455
"name": "bicep",
1451-
"version": "0.35.1.17967",
1452-
"templateHash": "12684246002053954621"
1456+
"version": "0.34.44.8038",
1457+
"templateHash": "14155463992250872710"
14531458
}
14541459
},
14551460
"parameters": {
@@ -1657,6 +1662,12 @@
16571662
"AZURE_OPENAI_RESOURCE": {
16581663
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry'), '2022-09-01').outputs.aiServicesName.value]"
16591664
},
1665+
"AzureOpenAIProjectConnString": {
1666+
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry'), '2022-09-01').outputs.azureProjectConnString.value]"
1667+
},
1668+
"AzureAIProjectName": {
1669+
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry'), '2022-09-01').outputs.aiProjectName.value]"
1670+
},
16601671
"USE_CHAT_HISTORY_ENABLED": {
16611672
"value": "True"
16621673
},
@@ -1680,6 +1691,9 @@
16801691
},
16811692
"WebsiteName": {
16821693
"value": "[format('{0}{1}', variables('abbrs').compute.webApp, variables('solutionPrefix'))]"
1694+
},
1695+
"useAiFoundrySdk": {
1696+
"value": "False"
16831697
}
16841698
},
16851699
"template": {
@@ -1688,8 +1702,8 @@
16881702
"metadata": {
16891703
"_generator": {
16901704
"name": "bicep",
1691-
"version": "0.35.1.17967",
1692-
"templateHash": "16988932665267526316"
1705+
"version": "0.34.44.8038",
1706+
"templateHash": "11947266873515406477"
16931707
}
16941708
},
16951709
"parameters": {
@@ -1760,6 +1774,18 @@
17601774
"description": "Azure OpenAI Key"
17611775
}
17621776
},
1777+
"AzureOpenAIProjectConnString": {
1778+
"type": "string",
1779+
"metadata": {
1780+
"description": "Azure Open AI Project Connection String"
1781+
}
1782+
},
1783+
"AzureAIProjectName": {
1784+
"type": "string",
1785+
"metadata": {
1786+
"description": "Azure AI project name"
1787+
}
1788+
},
17631789
"azureOpenAIApiVersion": {
17641790
"type": "string"
17651791
},
@@ -1907,6 +1933,13 @@
19071933
"description": "Enable feedback in Cosmos DB"
19081934
}
19091935
},
1936+
"useAiFoundrySdk": {
1937+
"type": "string",
1938+
"defaultValue": "False",
1939+
"metadata": {
1940+
"description": "Use AI Foundry SDK"
1941+
}
1942+
},
19101943
"imageTag": {
19111944
"type": "string"
19121945
},
@@ -2090,6 +2123,10 @@
20902123
"name": "AZURE_OPENAI_SYSTEM_MESSAGE",
20912124
"value": "[variables('azureOpenAISystemMessage')]"
20922125
},
2126+
{
2127+
"name": "AZURE_OPENAI_PROJECT_CONN_STRING",
2128+
"value": "[parameters('AzureOpenAIProjectConnString')]"
2129+
},
20932130
{
20942131
"name": "USE_CHAT_HISTORY_ENABLED",
20952132
"value": "[parameters('USE_CHAT_HISTORY_ENABLED')]"
@@ -2125,6 +2162,10 @@
21252162
{
21262163
"name": "UWSGI_THREADS",
21272164
"value": "2"
2165+
},
2166+
{
2167+
"name": "USE_AI_FOUNDRY_SDK",
2168+
"value": "[parameters('useAiFoundrySdk')]"
21282169
}
21292170
],
21302171
"linuxFxVersion": "[variables('imageName')]"
@@ -2146,6 +2187,19 @@
21462187
"dependsOn": [
21472188
"[resourceId('Microsoft.Web/sites', parameters('WebsiteName'))]"
21482189
]
2190+
},
2191+
{
2192+
"type": "Microsoft.Authorization/roleAssignments",
2193+
"apiVersion": "2022-04-01",
2194+
"scope": "[format('Microsoft.MachineLearningServices/workspaces/{0}', parameters('AzureAIProjectName'))]",
2195+
"name": "[guid(parameters('WebsiteName'), resourceId('Microsoft.MachineLearningServices/workspaces', parameters('AzureAIProjectName')), resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee'))]",
2196+
"properties": {
2197+
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee')]",
2198+
"principalId": "[reference(resourceId('Microsoft.Web/sites', parameters('WebsiteName')), '2020-06-01', 'full').identity.principalId]"
2199+
},
2200+
"dependsOn": [
2201+
"[resourceId('Microsoft.Web/sites', parameters('WebsiteName'))]"
2202+
]
21492203
}
21502204
],
21512205
"outputs": {
@@ -2191,8 +2245,8 @@
21912245
"metadata": {
21922246
"_generator": {
21932247
"name": "bicep",
2194-
"version": "0.35.1.17967",
2195-
"templateHash": "12799194170352887919"
2248+
"version": "0.34.44.8038",
2249+
"templateHash": "9693594232553540170"
21962250
}
21972251
},
21982252
"parameters": {

src/.env.sample

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ AZURE_OPENAI_ENDPOINT=
2727
AZURE_OPENAI_EMBEDDING_NAME=
2828
AZURE_OPENAI_EMBEDDING_ENDPOINT=
2929
AZURE_OPENAI_EMBEDDING_KEY=
30+
AZURE_OPENAI_PROJECT_CONN_STRING=
3031
# User Interface
3132
UI_TITLE=
3233
UI_LOGO=
@@ -120,4 +121,5 @@ PROMPTFLOW_API_KEY=
120121
PROMPTFLOW_RESPONSE_TIMEOUT=120
121122
PROMPTFLOW_REQUEST_FIELD_NAME=query
122123
PROMPTFLOW_RESPONSE_FIELD_NAME=reply
123-
PROMPTFLOW_CITATIONS_FIELD_NAME=documents
124+
PROMPTFLOW_CITATIONS_FIELD_NAME=documents
125+
USE_AI_FOUNDRY_SDK=False

0 commit comments

Comments
 (0)