11// ========== Key Vault ========== //
22targetScope = 'resourceGroup'
33
4- @minLength (3 )
5- @maxLength (15 )
64@description ('Solution Name' )
75param 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
0 commit comments