Skip to content

Commit f28f718

Browse files
Merge pull request #372 from microsoft/fix/error-analyzer-path-not-found
fix: Deploy AI model and Process Sample data manually
2 parents 250f99d + 778431d commit f28f718

25 files changed

Lines changed: 438 additions & 447 deletions

.devcontainer/devcontainer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
44
"forwardPorts": [50505],
55
"features": {
6-
"ghcr.io/azure/azure-dev/azd:latest": {}
6+
"ghcr.io/azure/azure-dev/azd:latest": {},
7+
"ghcr.io/jlaundry/devcontainer-features/mssql-odbc-driver:1": {
8+
"version": "18"
9+
},
10+
"ghcr.io/devcontainers/features/azure-cli:1": {},
11+
"ghcr.io/devcontainers/features/powershell:1": {}
712
},
813
"customizations": {
914
"vscode": {
@@ -16,7 +21,7 @@
1621
]
1722
}
1823
},
19-
"postStartCommand": "git pull origin main && python3 -m pip install -r infra/scripts/index_scripts/requirements.txt && curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash && chmod +x ./infra/scripts/quota_check_params.sh",
24+
"postStartCommand": "git pull origin main && python3 -m pip install -r infra/scripts/index_scripts/requirements.txt && chmod +x ./infra/scripts/quota_check_params.sh",
2025
"remoteUser": "vscode",
2126
"hostRequirements": {
2227
"memory": "4gb"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
.fake
1111
.azure
1212
.idea
13+
scriptenv/
14+
__pycache__/

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ If you're not using one of the above options for opening the project, then you'l
136136
* [Docker Desktop](https://www.docker.com/products/docker-desktop/)
137137
* [Git](https://git-scm.com/downloads)
138138
* [Powershell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5)<br/>Required for Windows users only. Follow the steps [here](./docs/PowershellSetup.md) to add it to the Windows PATH.
139+
* [ODBC Driver 18 for SQL Server](https://learn.microsoft.com/sql/connect/odbc/download-odbc-driver-for-sql-server)
139140

140141
2. Download the project code:
141142

@@ -189,10 +190,17 @@ To change the azd parameters from the default values, follow the steps [here](./
189190
190191
3. Provide an `azd` environment name (like "ckmapp")
191192
4. Select a subscription from your Azure account, and select a location which has quota for all the resources.
192-
* This deployment will take *7-10 minutes* to provision the resources in your account and set up the solution with sample data.
193+
* This deployment will take *7-10 minutes* to provision the resources in your account.
193194
* If you get an error or timeout with deployment, changing the location can help, as there may be availability constraints for the resources.
194-
195-
5. Once the deployment has completed successfully, open the [Azure Portal](https://portal.azure.com/), go to the deployed resource group, find the App Service and get the app URL from `Default domain`.
195+
5. Once the infrastructure deployment completes successfully, you can proceed with deploying the AI model by running the bash command displayed in the terminal. The command will look similar to the following:
196+
```shell
197+
bash ./infra/scripts/deploy_ai_model.sh <Resource-Group-Name> <Solution-Name> <OpenAI-Model-Deployment-Type> <OpenAI-Deployment-Model> <OpenAI-Deployment-Model-Capacity> <OpenAI-Embedding-Model> <OpenAI-Embedding-Model-Capacity> <Managed-Identity-Client-ID>
198+
```
199+
6. After the AI model deployment finishes, if you wish to load the sample data, you can then run the corresponding sample data processing command, which will also be shown in the terminal:
200+
```shell
201+
bash ./infra/scripts/process_sample_data.sh <Storage-Account-Name> <Storage-Container-Name> <Managed-Identity-Client-ID> <Key-Vault-Name> <SQLDB-Server> <SQLDB-Database> <Resource-Group-Name> <API-App-Managed-Identity-Client-ID> <API-App-Managed-Identity-Name>
202+
```
203+
7. Once the deployment has completed successfully, open the [Azure Portal](https://portal.azure.com/), go to the deployed resource group, find the App Service and get the app URL from `Default domain`.
196204
197205
6. You can now delete the resources by running `azd down`, if you are done trying out the application.
198206
<!-- 6. You can now proceed to run the [development server](#development-server) to test the app locally, or if you are done trying out the app, you can delete the resources by running `azd down`. -->
@@ -302,4 +310,4 @@ You acknowledge that the Software and Microsoft Products and Services (1) are no
302310

303311
You acknowledge the Software is not subject to SOC 1 and SOC 2 compliance audits. No Microsoft technology, nor any of its component technologies, including the Software, is intended or made available as a substitute for the professional advice, opinion, or judgement of a certified financial services professional. Do not use the Software to replace, substitute, or provide professional financial advice or judgment.
304312

305-
BY ACCESSING OR USING THE SOFTWARE, YOU ACKNOWLEDGE THAT THE SOFTWARE IS NOT DESIGNED OR INTENDED TO SUPPORT ANY USE IN WHICH A SERVICE INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE COULD RESULT IN THE DEATH OR SERIOUS BODILY INJURY OF ANY PERSON OR IN PHYSICAL OR ENVIRONMENTAL DAMAGE (COLLECTIVELY, “HIGH-RISK USE”), AND THAT YOU WILL ENSURE THAT, IN THE EVENT OF ANY INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE, THE SAFETY OF PEOPLE, PROPERTY, AND THE ENVIRONMENT ARE NOT REDUCED BELOW A LEVEL THAT IS REASONABLY, APPROPRIATE, AND LEGAL, WHETHER IN GENERAL OR IN A SPECIFIC INDUSTRY. BY ACCESSING THE SOFTWARE, YOU FURTHER ACKNOWLEDGE THAT YOUR HIGH-RISK USE OF THE SOFTWARE IS AT YOUR OWN RISK.
313+
BY ACCESSING OR USING THE SOFTWARE, YOU ACKNOWLEDGE THAT THE SOFTWARE IS NOT DESIGNED OR INTENDED TO SUPPORT ANY USE IN WHICH A SERVICE INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE COULD RESULT IN THE DEATH OR SERIOUS BODILY INJURY OF ANY PERSON OR IN PHYSICAL OR ENVIRONMENTAL DAMAGE (COLLECTIVELY, “HIGH-RISK USE”), AND THAT YOU WILL ENSURE THAT, IN THE EVENT OF ANY INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE, THE SAFETY OF PEOPLE, PROPERTY, AND THE ENVIRONMENT ARE NOT REDUCED BELOW A LEVEL THAT IS REASONABLY, APPROPRIATE, AND LEGAL, WHETHER IN GENERAL OR IN A SPECIFIC INDUSTRY. BY ACCESSING THE SOFTWARE, YOU FURTHER ACKNOWLEDGE THAT YOUR HIGH-RISK USE OF THE SOFTWARE IS AT YOUR OWN RISK.

azure.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ hooks:
1414
run: |
1515
Write-Host "Web app URL: "
1616
Write-Host "$env:WEB_APP_URL" -ForegroundColor Cyan
17+
Write-Host "🚀 If you want to deploy the AI Model, run the following command in the Bash terminal:"
18+
Write-Host "bash ./infra/scripts/deploy_ai_model.sh $env:RESOURCE_GROUP_NAME $env:SOLUTION_NAME $env:AZURE_OPEN_AI_MODEL_DEPLOYMENT_TYPE $env:AZURE_OPEN_AI_DEPLOYMENT_MODEL $env:AZURE_OPEN_AI_DEPLOYMENT_MODEL_CAPACITY $env:AZURE_OPENAI_EMBEDDING_MODEL $env:AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY $env:MANAGED_IDENTITY_CLIENT_ID" -ForegroundColor Cyan
1719
Write-Host "✅ If you want to use the Sample Data, run the following command in the Bash terminal to process it:"
18-
Write-Host "bash ./infra/scripts/process_sample_data.sh <storage_account_name> <storage_container_name> <managed_client_id> <key_vault_name> <sql_server_name> <sql_database_name> <resource_group_name>" -ForegroundColor Cyan
20+
Write-Host "bash ./infra/scripts/process_sample_data.sh $env:STORAGE_ACCOUNT_NAME $env:STORAGE_CONTAINER_NAME $env:MANAGED_IDENTITY_CLIENT_ID $env:KEY_VAULT_NAME $env:SQLDB_SERVER $env:SQLDB_DATABASE $env:RESOURCE_GROUP_NAME $env:API_APP_MANAGED_IDENTITY_CLIENT_ID $env:API_APP_MANAGED_IDENTITY_NAME" -ForegroundColor Cyan
1921
shell: pwsh
2022
continueOnError: false
2123
interactive: true
2224
posix:
2325
run: |
2426
echo "Web app URL: "
2527
echo $WEB_APP_URL
28+
echo "🚀 If you want to deploy the AI Model, run the following command in the Bash terminal:"
29+
echo "bash ./infra/scripts/deploy_ai_model.sh $RESOURCE_GROUP_NAME $SOLUTION_NAME $AZURE_OPEN_AI_MODEL_DEPLOYMENT_TYPE $AZURE_OPEN_AI_DEPLOYMENT_MODEL $AZURE_OPEN_AI_DEPLOYMENT_MODEL_CAPACITY $AZURE_OPENAI_EMBEDDING_MODEL $AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY $MANAGED_IDENTITY_CLIENT_ID"
2630
echo "✅ If you want to use the Sample Data, run the following command in the Bash terminal to process it:"
27-
echo "bash ./infra/scripts/process_sample_data.sh <storage_account_name> <storage_container_name> <managed_client_id> <key_vault_name> <sql_server_name> <sql_database_name> <resource_group_name>"
31+
echo "bash ./infra/scripts/process_sample_data.sh $STORAGE_ACCOUNT_NAME $STORAGE_CONTAINER_NAME $MANAGED_IDENTITY_CLIENT_ID $KEY_VAULT_NAME $SQLDB_SERVER $SQLDB_DATABASE $RESOURCE_GROUP_NAME $API_APP_MANAGED_IDENTITY_CLIENT_ID $API_APP_MANAGED_IDENTITY_NAME"
2832
shell: sh
2933
continueOnError: false
3034
interactive: true

docs/CustomizingAzdParameters.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,41 @@ By default this template will use the environment name as the prefix to prevent
88
Change the Content Understanding Location (allowed values: Sweden Central, Australia East)
99

1010
```shell
11-
azd env set AZURE_ENV_CU_LOCATION 'swedencentral'
11+
azd env set AZURE_CONTENT_UNDERSTANDING_LOCATION 'swedencentral'
1212
```
1313

1414
Change the Secondary Location (example: eastus2, westus2, etc.)
1515

1616
```shell
17-
azd env set AZURE_ENV_SECONDARY_LOCATION eastus2
17+
azd env set AZURE_SECONDARY_LOCATION eastus2
1818
```
1919

2020
Change the Model Deployment Type (allowed values: Standard, GlobalStandard)
2121

2222
```shell
23-
azd env set AZURE_ENV_MODEL_DEPLOYMENT_TYPE GlobalStandard
23+
azd env set AZURE_OPEN_AI_MODEL_DEPLOYMENT_TYPE GlobalStandard
2424
```
2525

2626
Set the Model Name (allowed values: gpt-4o-mini, gpt-4o, gpt-4)
2727

2828
```shell
29-
azd env set AZURE_ENV_MODEL_NAME gpt-4o-mini
29+
azd env set AZURE_OPEN_AI_DEPLOYMENT_MODEL gpt-4o-mini
3030
```
3131

3232
Change the Model Capacity (choose a number based on available GPT model capacity in your subscription)
3333

3434
```shell
35-
azd env set AZURE_ENV_MODEL_CAPACITY 30
35+
azd env set AZURE_OPEN_AI_DEPLOYMENT_MODEL_CAPACITY 30
3636
```
3737

3838
Change the Embedding Model
3939

4040
```shell
41-
azd env set AZURE_ENV_EMBEDDING_MODEL_NAME text-embedding-ada-002
41+
azd env set AZURE_OPENAI_EMBEDDING_MODEL text-embedding-ada-002
4242
```
4343

4444
Change the Embedding Deployment Capacity (choose a number based on available embedding model capacity in your subscription)
4545

4646
```shell
47-
azd env set AZURE_ENV_EMBEDDING_MODEL_CAPACITY 80
47+
azd env set AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY 80
4848
```

infra/deploy_ai_foundry.bicep

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,6 @@ var aiHubDescription = 'AI Hub for KM template'
2929
var aiProjectName = '${solutionName}-aiproject'
3030
var aiProjectFriendlyName = aiProjectName
3131
var aiSearchName = '${solutionName}-search'
32-
var aiModelDeployments = [
33-
{
34-
name: gptModelName
35-
model: gptModelName
36-
sku: {
37-
name: deploymentType
38-
capacity: gptDeploymentCapacity
39-
}
40-
raiPolicyName: 'Microsoft.Default'
41-
}
42-
{
43-
name: embeddingModel
44-
model: embeddingModel
45-
sku: {
46-
name: 'Standard'
47-
capacity: embeddingDeploymentCapacity
48-
}
49-
raiPolicyName: 'Microsoft.Default'
50-
}
51-
]
5232

5333
var containerRegistryNameCleaned = replace(containerRegistryName, '-', '')
5434

@@ -217,23 +197,6 @@ resource aiServices_CU 'Microsoft.CognitiveServices/accounts@2024-04-01-preview'
217197
}
218198
}
219199

220-
@batchSize(1)
221-
resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for aiModeldeployment in aiModelDeployments: {
222-
parent: aiServices //aiServices_m
223-
name: aiModeldeployment.name
224-
properties: {
225-
model: {
226-
format: 'OpenAI'
227-
name: aiModeldeployment.model
228-
}
229-
raiPolicyName: aiModeldeployment.raiPolicyName
230-
}
231-
sku:{
232-
name: aiModeldeployment.sku.name
233-
capacity: aiModeldeployment.sku.capacity
234-
}
235-
}]
236-
237200
resource aiSearch 'Microsoft.Search/searchServices@2023-11-01' = {
238201
name: aiSearchName
239202
location: solutionLocation
@@ -421,7 +384,7 @@ resource aiHub 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview'
421384
}
422385
}
423386
dependsOn: [
424-
aiServicesDeployments,aiSearch
387+
aiSearch
425388
]
426389
}
427390

@@ -445,7 +408,7 @@ resource aiHub 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview'
445408
}
446409
}
447410
dependsOn: [
448-
aiServicesDeployments,aiSearch
411+
aiSearch
449412
]
450413
}
451414

infra/deploy_ai_model.bicep

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
param solutionName string
2+
param deploymentType string
3+
param gptModelName string
4+
param gptDeploymentCapacity int
5+
param embeddingModel string
6+
param embeddingDeploymentCapacity int
7+
var aiServicesName = '${solutionName}-aiservices'
8+
var aiModelDeployments = [
9+
{
10+
name: gptModelName
11+
model: gptModelName
12+
sku: {
13+
name: deploymentType
14+
capacity: gptDeploymentCapacity
15+
}
16+
raiPolicyName: 'Microsoft.Default'
17+
}
18+
{
19+
name: embeddingModel
20+
model: embeddingModel
21+
sku: {
22+
name: 'Standard'
23+
capacity: embeddingDeploymentCapacity
24+
}
25+
raiPolicyName: 'Microsoft.Default'
26+
}
27+
]
28+
29+
resource existingAiServices 'Microsoft.CognitiveServices/accounts@2024-10-01' existing = {
30+
name: aiServicesName
31+
}
32+
33+
@batchSize(1)
34+
resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for aiModeldeployment in aiModelDeployments: {
35+
parent: existingAiServices
36+
name: aiModeldeployment.name
37+
properties: {
38+
model: {
39+
format: 'OpenAI'
40+
name: aiModeldeployment.model
41+
}
42+
raiPolicyName: aiModeldeployment.raiPolicyName
43+
}
44+
sku:{
45+
name: aiModeldeployment.sku.name
46+
capacity: aiModeldeployment.sku.capacity
47+
}
48+
}]

infra/main.bicep

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ var resourceGroupLocation = resourceGroup().location
7171
// var resourceGroupName = resourceGroup().name
7272

7373
var solutionLocation = resourceGroupLocation
74-
var baseUrl = 'https://raw.githubusercontent.com/microsoft/Conversation-Knowledge-Mining-Solution-Accelerator/main/'
75-
7674

7775
// ========== Managed Identity ========== //
7876
module managedIdentityModule 'deploy_managed_identity.bicep' = {
@@ -244,4 +242,43 @@ module frontend_docker 'deploy_frontend_docker.bicep'= {
244242
scope: resourceGroup(resourceGroup().name)
245243
}
246244

245+
output SOLUTION_NAME string = solutionPrefix
246+
output RESOURCE_GROUP_NAME string = resourceGroup().name
247+
output RESOURCE_GROUP_LOCATION string = resourceGroupLocation
248+
output ENVIRONMENT_NAME string = environmentName
249+
output AZURE_CONTENT_UNDERSTANDING_LOCATION string = contentUnderstandingLocation
250+
output AZURE_SECONDARY_LOCATION string = secondaryLocation
251+
output APPINSIGHTS_INSTRUMENTATIONKEY string = ''
252+
output AZURE_AI_PROJECT_CONN_STRING string = ''
253+
output AZURE_AI_SEARCH_API_KEY string = ''
254+
output AZURE_AI_SEARCH_ENDPOINT string = aifoundry.outputs.aiSearchTarget
255+
output AZURE_AI_SEARCH_INDEX string = 'call_transcripts_index'
256+
output AZURE_COSMOSDB_ACCOUNT string = cosmosDBModule.outputs.cosmosAccountName
257+
output AZURE_COSMOSDB_CONVERSATIONS_CONTAINER string = 'conversations'
258+
output AZURE_COSMOSDB_DATABASE string = 'db_conversation_history'
259+
output AZURE_COSMOSDB_ENABLE_FEEDBACK string = 'True'
260+
output AZURE_OPEN_AI_DEPLOYMENT_MODEL string = gptModelName
261+
output AZURE_OPEN_AI_DEPLOYMENT_MODEL_CAPACITY int = gptDeploymentCapacity
262+
output AZURE_OPEN_AI_ENDPOINT string = aifoundry.outputs.aiServicesTarget
263+
output AZURE_OPENAI_API_KEY string = ''
264+
output AZURE_OPEN_AI_MODEL_DEPLOYMENT_TYPE string = deploymentType
265+
output AZURE_OPENAI_EMBEDDING_MODEL string = embeddingModel
266+
output AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY int = embeddingDeploymentCapacity
267+
output AZURE_OPENAI_API_VERSION string = azureOpenAIApiVersion
268+
output AZURE_OPENAI_RESOURCE string = aifoundry.outputs.aiServicesName
269+
output OPENAI_API_VERSION string = azureOpenAIApiVersion
270+
output SQLDB_DATABASE string = sqlDBModule.outputs.sqlDbName
271+
output SQLDB_SERVER string = sqlDBModule.outputs.sqlServerName
272+
output SQLDB_USER_MID string = managedIdentityModule.outputs.managedIdentityBackendAppOutput.clientId
273+
output SQLDB_USERNAME string = sqlDBModule.outputs.sqlDbUser
274+
output USE_AI_PROJECT_CLIENT string = 'False'
275+
output USE_CHAT_HISTORY_ENABLED string = 'True'
276+
277+
output MANAGED_IDENTITY_CLIENT_ID string = managedIdentityModule.outputs.managedIdentityOutput.clientId
278+
output STORAGE_ACCOUNT_NAME string = storageAccount.outputs.storageName
279+
output STORAGE_CONTAINER_NAME string = storageAccount.outputs.storageContainer
280+
output KEY_VAULT_NAME string = kvault.outputs.keyvaultName
281+
output API_APP_MANAGED_IDENTITY_CLIENT_ID string = managedIdentityModule.outputs.managedIdentityBackendAppOutput.clientId
282+
output API_APP_MANAGED_IDENTITY_NAME string = managedIdentityModule.outputs.managedIdentityBackendAppOutput.name
283+
output API_APP_URL string = backend_docker.outputs.appUrl
247284
output WEB_APP_URL string = frontend_docker.outputs.appUrl

infra/main.bicepparam

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using './main.bicep'
22

33
param environmentName = readEnvironmentVariable('AZURE_ENV_NAME', 'env_name')
4-
param contentUnderstandingLocation = readEnvironmentVariable('AZURE_ENV_CU_LOCATION', 'swedencentral')
5-
param secondaryLocation = readEnvironmentVariable('AZURE_ENV_SECONDARY_LOCATION', 'eastus2')
6-
param deploymentType = readEnvironmentVariable('AZURE_ENV_MODEL_DEPLOYMENT_TYPE', 'GlobalStandard')
7-
param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o-mini')
8-
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_MODEL_CAPACITY', '30'))
9-
param embeddingModel = readEnvironmentVariable('AZURE_ENV_EMBEDDING_MODEL_NAME', 'text-embedding-ada-002')
10-
param embeddingDeploymentCapacity = int(readEnvironmentVariable('AZURE_ENV_EMBEDDING_MODEL_CAPACITY', '80'))
4+
param contentUnderstandingLocation = readEnvironmentVariable('AZURE_CONTENT_UNDERSTANDING_LOCATION', 'swedencentral')
5+
param secondaryLocation = readEnvironmentVariable('AZURE_SECONDARY_LOCATION', 'eastus2')
6+
param deploymentType = readEnvironmentVariable('AZURE_OPEN_AI_MODEL_DEPLOYMENT_TYPE', 'GlobalStandard')
7+
param gptModelName = readEnvironmentVariable('AZURE_OPEN_AI_DEPLOYMENT_MODEL', 'gpt-4o-mini')
8+
param gptDeploymentCapacity = int(readEnvironmentVariable('AZURE_OPEN_AI_DEPLOYMENT_MODEL_CAPACITY', '30'))
9+
param embeddingModel = readEnvironmentVariable('AZURE_OPENAI_EMBEDDING_MODEL', 'text-embedding-ada-002')
10+
param embeddingDeploymentCapacity = int(readEnvironmentVariable('AZURE_OPENAI_EMBEDDING_MODEL_CAPACITY', '80'))

0 commit comments

Comments
 (0)