Skip to content

Commit 6215c5a

Browse files
Merge pull request #329 from microsoft/psl-pk-migra-km
feat!: Migrate Chat and Chart Functionality from Function App to App Service
2 parents fcac902 + dbf4cc1 commit 6215c5a

File tree

136 files changed

+3023
-3613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+3023
-3613
lines changed

.github/workflows/docker-build.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
id: determine_tag
5050
run: |
5151
if [[ "${{ github.ref_name }}" == "main" ]]; then
52-
echo "tagname=latest" >> $GITHUB_OUTPUT
52+
echo "tagname=latest_migra" >> $GITHUB_OUTPUT
5353
elif [[ "${{ github.ref_name }}" == "dev" ]]; then
5454
echo "tagname=dev" >> $GITHUB_OUTPUT
5555
elif [[ "${{ github.ref_name }}" == "demo" ]]; then
@@ -70,22 +70,12 @@ jobs:
7070
${{ secrets.ACR_LOGIN_SERVER }}/km-app:${{ steps.determine_tag.outputs.tagname }}
7171
${{ secrets.ACR_LOGIN_SERVER }}/km-app:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
7272
73-
- name: Build and Push Docker Image for km-rag-function
73+
- name: Build and Push Docker Image for api
7474
uses: docker/build-push-action@v6
7575
with:
76-
context: ./src/api/km-rag-function
77-
file: ./src/api/km-rag-function/Dockerfile
76+
context: ./src/api
77+
file: ./src/api/ApiApp.Dockerfile
7878
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
7979
tags: |
80-
${{ secrets.ACR_LOGIN_SERVER }}/km-rag-function:${{ steps.determine_tag.outputs.tagname }}
81-
${{ secrets.ACR_LOGIN_SERVER }}/km-rag-function:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
82-
83-
- name: Build and Push Docker Image for km-charts-function
84-
uses: docker/build-push-action@v6
85-
with:
86-
context: ./src/api/km-charts-function
87-
file: ./src/api/km-charts-function/Dockerfile
88-
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
89-
tags: |
90-
${{ secrets.ACR_LOGIN_SERVER }}/km-charts-function:${{ steps.determine_tag.outputs.tagname }}
91-
${{ secrets.ACR_LOGIN_SERVER }}/km-charts-function:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
80+
${{ secrets.ACR_LOGIN_SERVER }}/km-api:${{ steps.determine_tag.outputs.tagname }}
81+
${{ secrets.ACR_LOGIN_SERVER }}/km-api:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}

.github/workflows/pylint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
22-
pip install -r src/App/requirements.txt
22+
pip install -r src/api/requirements.txt
2323
pip install flake8 # Ensure flake8 is installed explicitly
2424
2525
- name: Run flake8 and pylint
2626
run: |
27-
flake8 --config=.flake8 src/App/backend # Specify the directory to lint
27+
flake8 --config=.flake8 src/api # Specify the directory to lint

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
################################################################################
22
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
33
################################################################################
4-
*.env
54
*.venv
65
*.vscode
76
*.vs
@@ -10,3 +9,4 @@
109
/LUISSchemaSerializationTool/LUISSchemaSerializationTool/obj
1110
.fake
1211
.azure
12+
.idea

infra/deploy_ai_foundry.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,3 +701,5 @@ output aiProjectName string = aiHubProject.name
701701
output applicationInsightsId string = applicationInsights.id
702702
output logAnalyticsWorkspaceResourceName string = logAnalytics.name
703703
output storageAccountName string = storageNameCleaned
704+
705+
output azureOpenAIKeyName string = azureOpenAIApiKeyEntry.name

infra/deploy_app_service.bicep

Lines changed: 31 additions & 241 deletions
Original file line numberDiff line numberDiff line change
@@ -1,231 +1,32 @@
11
// ========== Key Vault ========== //
22
targetScope = 'resourceGroup'
33

4-
@minLength(3)
5-
@maxLength(15)
64
@description('Solution Name')
75
param solutionName string
86

9-
// @description('Solution Location')
10-
// param solutionLocation string
11-
12-
// param identity string
13-
14-
@description('Name of App Service plan')
15-
param HostingPlanName string = '${ solutionName }-app-service-plan'
16-
17-
@description('The pricing tier for the App Service plan')
18-
@allowed(
19-
['F1', 'D1', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3', 'P4','P0v3']
20-
)
21-
// param HostingPlanSku string = 'B1'
22-
23-
param HostingPlanSku string = 'P0v3'
24-
25-
@description('Name of Web App')
26-
param WebsiteName string = '${ solutionName }-app-service'
27-
28-
// @description('Name of Application Insights')
29-
// param ApplicationInsightsName string = '${ solutionName }-app-insights'
30-
31-
@description('Azure OpenAI Model Deployment Name')
32-
param AzureOpenAIModel string
33-
34-
@description('Azure Open AI Endpoint')
35-
param AzureOpenAIEndpoint string = ''
36-
37-
@description('Azure OpenAI Key')
387
@secure()
39-
param AzureOpenAIKey string
40-
41-
param azureOpenAIApiVersion string
42-
param AZURE_OPENAI_RESOURCE string = ''
43-
param CHARTS_URL string = ''
44-
param FILTERS_URL string = ''
45-
param USE_GRAPHRAG string = ''
46-
param GRAPHRAG_URL string = ''
47-
param RAG_URL string = ''
48-
param USE_CHAT_HISTORY_ENABLED string = ''
49-
50-
@description('Azure Cosmos DB Account')
51-
param AZURE_COSMOSDB_ACCOUNT string = ''
52-
53-
// @description('Azure Cosmos DB Account Key')
54-
// @secure()
55-
// param AZURE_COSMOSDB_ACCOUNT_KEY string = ''
56-
57-
@description('Azure Cosmos DB Conversations Container')
58-
param AZURE_COSMOSDB_CONVERSATIONS_CONTAINER string = ''
59-
60-
@description('Azure Cosmos DB Database')
61-
param AZURE_COSMOSDB_DATABASE string = ''
62-
63-
@description('Enable feedback in Cosmos DB')
64-
param AZURE_COSMOSDB_ENABLE_FEEDBACK string = 'True'
65-
66-
param imageTag string
67-
param applicationInsightsId string
68-
// var WebAppImageName = 'DOCKER|byoaiacontainer.azurecr.io/byoaia-app:latest'
8+
param appSettings object = {}
9+
param appServicePlanId string
10+
param appImageName string
11+
param userassignedIdentityId string = ''
6912

70-
// var WebAppImageName = 'DOCKER|ncwaappcontainerreg1.azurecr.io/ncqaappimage:v1.0.0'
71-
72-
var WebAppImageName = 'DOCKER|kmcontainerreg.azurecr.io/km-app:${imageTag}'
73-
74-
resource HostingPlan 'Microsoft.Web/serverfarms@2020-06-01' = {
75-
name: HostingPlanName
76-
location: resourceGroup().location
77-
sku: {
78-
name: HostingPlanSku
79-
}
80-
properties: {
81-
name: HostingPlanName
82-
reserved: true
83-
}
84-
kind: 'linux'
85-
}
86-
var REACT_APP_LAYOUT_CONFIG ='''{
87-
"appConfig": {
88-
"THREE_COLUMN": {
89-
"DASHBOARD": 50,
90-
"CHAT": 33,
91-
"CHATHISTORY": 17
92-
},
93-
"TWO_COLUMN": {
94-
"DASHBOARD_CHAT": {
95-
"DASHBOARD": 65,
96-
"CHAT": 35
97-
},
98-
"CHAT_CHATHISTORY": {
99-
"CHAT": 80,
100-
"CHATHISTORY": 20
101-
}
102-
}
103-
},
104-
"charts": [
105-
{
106-
"id": "SATISFIED",
107-
"name": "Satisfied",
108-
"type": "card",
109-
"layout": { "row": 1, "column": 1, "height": 11 }
110-
},
111-
{
112-
"id": "TOTAL_CALLS",
113-
"name": "Total Calls",
114-
"type": "card",
115-
"layout": { "row": 1, "column": 2, "span": 1 }
116-
},
117-
{
118-
"id": "AVG_HANDLING_TIME",
119-
"name": "Average Handling Time",
120-
"type": "card",
121-
"layout": { "row": 1, "column": 3, "span": 1 }
122-
},
123-
{
124-
"id": "SENTIMENT",
125-
"name": "Topics Overview",
126-
"type": "donutchart",
127-
"layout": { "row": 2, "column": 1, "width": 40, "height": 44.5 }
128-
},
129-
{
130-
"id": "AVG_HANDLING_TIME_BY_TOPIC",
131-
"name": "Average Handling Time By Topic",
132-
"type": "bar",
133-
"layout": { "row": 2, "column": 2, "row-span": 2, "width": 60 }
134-
},
135-
{
136-
"id": "TOPICS",
137-
"name": "Trending Topics",
138-
"type": "table",
139-
"layout": { "row": 3, "column": 1, "span": 2 }
140-
},
141-
{
142-
"id": "KEY_PHRASES",
143-
"name": "Key Phrases",
144-
"type": "wordcloud",
145-
"layout": { "row": 3, "column": 2, "height": 44.5 }
146-
}
147-
]
148-
}'''
149-
150-
resource Website 'Microsoft.Web/sites@2020-06-01' = {
151-
name: WebsiteName
13+
resource appService 'Microsoft.Web/sites@2020-06-01' = {
14+
name: solutionName
15215
location: resourceGroup().location
153-
identity: {
16+
identity: userassignedIdentityId == '' ? {
15417
type: 'SystemAssigned'
155-
}
18+
} : {
19+
type: 'SystemAssigned, UserAssigned'
20+
userAssignedIdentities: {
21+
'${userassignedIdentityId}': {}
22+
}
23+
}
15624
properties: {
157-
serverFarmId: HostingPlanName
25+
serverFarmId: appServicePlanId
15826
siteConfig: {
15927
alwaysOn: true
16028
ftpsState: 'Disabled'
161-
appSettings: [
162-
{
163-
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
164-
value: reference(applicationInsightsId, '2015-05-01').InstrumentationKey
165-
}
166-
{
167-
name: 'AZURE_OPENAI_API_VERSION'
168-
value: azureOpenAIApiVersion
169-
}
170-
{
171-
name: 'AZURE_OPENAI_DEPLOYMENT_NAME'
172-
value: AzureOpenAIModel
173-
}
174-
{
175-
name: 'AZURE_OPENAI_ENDPOINT'
176-
value: AzureOpenAIEndpoint
177-
}
178-
{
179-
name: 'AZURE_OPENAI_API_KEY'
180-
value: AzureOpenAIKey
181-
}
182-
{
183-
name: 'AZURE_OPENAI_RESOURCE'
184-
value: AZURE_OPENAI_RESOURCE
185-
}
186-
{
187-
name: 'AZURE_OPENAI_PREVIEW_API_VERSION'
188-
value: azureOpenAIApiVersion
189-
}
190-
{
191-
name: 'USE_CHAT_HISTORY_ENABLED'
192-
value: USE_CHAT_HISTORY_ENABLED
193-
}
194-
{name: 'USE_GRAPHRAG', value: USE_GRAPHRAG}
195-
{name: 'CHART_DASHBOARD_URL', value: CHARTS_URL}
196-
{name: 'CHART_DASHBOARD_FILTERS_URL', value: FILTERS_URL}
197-
{name: 'GRAPHRAG_URL', value: GRAPHRAG_URL}
198-
{name: 'RAG_URL', value: RAG_URL}
199-
{name: 'REACT_APP_LAYOUT_CONFIG', value: REACT_APP_LAYOUT_CONFIG}
200-
{name: 'AZURE_COSMOSDB_ACCOUNT'
201-
value: AZURE_COSMOSDB_ACCOUNT
202-
}
203-
{name: 'AZURE_COSMOSDB_ACCOUNT_KEY'
204-
value: '' //AZURE_COSMOSDB_ACCOUNT_KEY
205-
}
206-
{name: 'AZURE_COSMOSDB_CONVERSATIONS_CONTAINER'
207-
value: AZURE_COSMOSDB_CONVERSATIONS_CONTAINER
208-
}
209-
{name: 'AZURE_COSMOSDB_DATABASE'
210-
value: AZURE_COSMOSDB_DATABASE
211-
}
212-
{name: 'AZURE_COSMOSDB_ENABLE_FEEDBACK'
213-
value: AZURE_COSMOSDB_ENABLE_FEEDBACK
214-
}
215-
{
216-
name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'
217-
value: 'true'
218-
}
219-
{
220-
name: 'UWSGI_PROCESSES'
221-
value: '2'
222-
}
223-
{
224-
name: 'UWSGI_THREADS'
225-
value: '2'
226-
}
227-
]
228-
linuxFxVersion: WebAppImageName
29+
linuxFxVersion: appImageName
22930
}
23031
}
23132
resource basicPublishingCredentialsPoliciesFtp 'basicPublishingCredentialsPolicies' = {
@@ -240,39 +41,28 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
24041
allow: false
24142
}
24243
}
243-
dependsOn: [HostingPlan]
24444
}
24545

246-
// resource ApplicationInsights 'Microsoft.Insights/components@2020-02-02' = {
247-
// name: ApplicationInsightsName
248-
// location: resourceGroup().location
249-
// tags: {
250-
// 'hidden-link:${resourceId('Microsoft.Web/sites',ApplicationInsightsName)}': 'Resource'
251-
// }
252-
// properties: {
253-
// Application_Type: 'web'
254-
// }
255-
// kind: 'web'
256-
// }
257-
258-
resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' existing = {
259-
name: AZURE_COSMOSDB_ACCOUNT
260-
}
261-
262-
resource contributorRoleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2024-05-15' existing = {
263-
name: '${AZURE_COSMOSDB_ACCOUNT}/00000000-0000-0000-0000-000000000002'
46+
module configAppSettings 'deploy_appservice-appsettings.bicep' = {
47+
name: '${appService.name}-appSettings'
48+
params: {
49+
name: appService.name
50+
appSettings: appSettings
51+
}
26452
}
26553

266-
resource role 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = {
267-
parent: cosmos
268-
name: guid(contributorRoleDefinition.id, cosmos.id)
54+
resource configLogs 'Microsoft.Web/sites/config@2022-03-01' = {
55+
name: 'logs'
56+
parent: appService
26957
properties: {
270-
principalId: Website.identity.principalId
271-
roleDefinitionId: contributorRoleDefinition.id
272-
scope: cosmos.id
58+
applicationLogs: { fileSystem: { level: 'Verbose' } }
59+
detailedErrorMessages: { enabled: true }
60+
failedRequestsTracing: { enabled: true }
61+
httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } }
27362
}
274-
dependsOn: [Website]
63+
dependsOn: [configAppSettings]
27564
}
27665

277-
output webAppUrl string = 'https://${WebsiteName}.azurewebsites.net'
66+
output identityPrincipalId string = appService.identity.principalId
67+
output appUrl string = 'https://${solutionName}.azurewebsites.net'
27868

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
metadata description = 'Creates an Azure App Service plan.'
2+
param solutionName string
3+
4+
@description('Name of App Service plan')
5+
param HostingPlanName string = '${ solutionName }-app-service-plan'
6+
7+
@description('The pricing tier for the App Service plan')
8+
@allowed(
9+
['F1', 'D1', 'B1', 'B2', 'B3', 'S1', 'S2', 'S3', 'P1', 'P2', 'P3', 'P4','P0v3']
10+
)
11+
param HostingPlanSku string = 'P0v3'
12+
13+
resource HostingPlan 'Microsoft.Web/serverfarms@2020-06-01' = {
14+
name: HostingPlanName
15+
location: resourceGroup().location
16+
sku: {
17+
name: HostingPlanSku
18+
}
19+
properties: {
20+
reserved: true
21+
}
22+
kind: 'linux'
23+
}
24+
25+
output id string = HostingPlan.id
26+
output name string = HostingPlan.name

0 commit comments

Comments
 (0)