Skip to content

Commit 89548a5

Browse files
fix: Merge pull request #246 from microsoft/psl-bug-14637
fix: Removed duplicate application insights
2 parents fb37ca7 + 0dbca00 commit 89548a5

File tree

4 files changed

+49
-41
lines changed

4 files changed

+49
-41
lines changed

infra/deploy_ai_foundry.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,4 +658,6 @@ output aiSearchId string = aiSearch.id
658658
output aiSearchTarget string = 'https://${aiSearch.name}.search.windows.net'
659659
output aiSearchService string = aiSearch.name
660660
output aiProjectName string = aiHubProject.name
661+
662+
output applicationInsightsId string = applicationInsights.id
661663
output storageAccountName string = storageNameCleaned

infra/deploy_app_service.bicep

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ param HostingPlanSku string = 'P0v3'
2525
@description('Name of Web App')
2626
param WebsiteName string = '${ solutionName }-app-service'
2727

28-
@description('Name of Application Insights')
29-
param ApplicationInsightsName string = '${ solutionName }-app-insights'
28+
// @description('Name of Application Insights')
29+
// param ApplicationInsightsName string = '${ solutionName }-app-insights'
3030

3131
@description('Azure OpenAI Model Deployment Name')
3232
param AzureOpenAIModel string
@@ -64,6 +64,7 @@ param AZURE_COSMOSDB_DATABASE string = ''
6464
param AZURE_COSMOSDB_ENABLE_FEEDBACK string = 'True'
6565

6666
param imageTag string
67+
param applicationInsightsId string
6768
// var WebAppImageName = 'DOCKER|byoaiacontainer.azurecr.io/byoaia-app:latest'
6869

6970
// var WebAppImageName = 'DOCKER|ncwaappcontainerreg1.azurecr.io/ncqaappimage:v1.0.0'
@@ -160,7 +161,7 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
160161
appSettings: [
161162
{
162163
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
163-
value: reference(ApplicationInsights.id, '2015-05-01').InstrumentationKey
164+
value: reference(applicationInsightsId, '2015-05-01').InstrumentationKey
164165
}
165166
{
166167
name: 'AZURE_OPENAI_API_VERSION'
@@ -242,17 +243,17 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
242243
dependsOn: [HostingPlan]
243244
}
244245

245-
resource ApplicationInsights 'Microsoft.Insights/components@2020-02-02' = {
246-
name: ApplicationInsightsName
247-
location: resourceGroup().location
248-
tags: {
249-
'hidden-link:${resourceId('Microsoft.Web/sites',ApplicationInsightsName)}': 'Resource'
250-
}
251-
properties: {
252-
Application_Type: 'web'
253-
}
254-
kind: 'web'
255-
}
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+
// }
256257

257258
resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' existing = {
258259
name: AZURE_COSMOSDB_ACCOUNT
@@ -273,4 +274,5 @@ resource role 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-
273274
dependsOn: [Website]
274275
}
275276

277+
output webAppUrl string = 'https://${WebsiteName}.azurewebsites.net'
276278

infra/main.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ module appserviceModule 'deploy_app_service.bicep' = {
237237
name: 'deploy_app_service'
238238
params: {
239239
imageTag: imageTag
240+
applicationInsightsId: aifoundry.outputs.applicationInsightsId
240241
// identity:managedIdentityModule.outputs.managedIdentityOutput.id
241242
solutionName: solutionPrefix
242243
// solutionLocation: solutionLocation
@@ -260,3 +261,5 @@ module appserviceModule 'deploy_app_service.bicep' = {
260261
scope: resourceGroup(resourceGroup().name)
261262
dependsOn:[sqlDBModule]
262263
}
264+
265+
output WEB_APP_URL string = appserviceModule.outputs.webAppUrl

infra/main.json

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.33.93.31351",
8-
"templateHash": "15021662036060306033"
8+
"templateHash": "6443985593110817960"
99
}
1010
},
1111
"parameters": {
@@ -366,7 +366,7 @@
366366
"_generator": {
367367
"name": "bicep",
368368
"version": "0.33.93.31351",
369-
"templateHash": "6605413385617905631"
369+
"templateHash": "12900062765650369722"
370370
}
371371
},
372372
"parameters": {
@@ -1019,6 +1019,10 @@
10191019
"type": "string",
10201020
"value": "[variables('aiProjectName')]"
10211021
},
1022+
"applicationInsightsId": {
1023+
"type": "string",
1024+
"value": "[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
1025+
},
10221026
"storageAccountName": {
10231027
"type": "string",
10241028
"value": "[variables('storageNameCleaned')]"
@@ -2295,6 +2299,9 @@
22952299
"imageTag": {
22962300
"value": "[parameters('imageTag')]"
22972301
},
2302+
"applicationInsightsId": {
2303+
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry'), '2022-09-01').outputs.applicationInsightsId.value]"
2304+
},
22982305
"solutionName": {
22992306
"value": "[variables('solutionPrefix')]"
23002307
},
@@ -2356,7 +2363,7 @@
23562363
"_generator": {
23572364
"name": "bicep",
23582365
"version": "0.33.93.31351",
2359-
"templateHash": "2254598285697484618"
2366+
"templateHash": "5835426116727035307"
23602367
}
23612368
},
23622369
"parameters": {
@@ -2404,13 +2411,6 @@
24042411
"description": "Name of Web App"
24052412
}
24062413
},
2407-
"ApplicationInsightsName": {
2408-
"type": "string",
2409-
"defaultValue": "[format('{0}-app-insights', parameters('solutionName'))]",
2410-
"metadata": {
2411-
"description": "Name of Application Insights"
2412-
}
2413-
},
24142414
"AzureOpenAIModel": {
24152415
"type": "string",
24162416
"metadata": {
@@ -2491,6 +2491,9 @@
24912491
},
24922492
"imageTag": {
24932493
"type": "string"
2494+
},
2495+
"applicationInsightsId": {
2496+
"type": "string"
24942497
}
24952498
},
24962499
"variables": {
@@ -2550,7 +2553,7 @@
25502553
"appSettings": [
25512554
{
25522555
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
2553-
"value": "[reference(resourceId('Microsoft.Insights/components', parameters('ApplicationInsightsName')), '2015-05-01').InstrumentationKey]"
2556+
"value": "[reference(parameters('applicationInsightsId'), '2015-05-01').InstrumentationKey]"
25542557
},
25552558
{
25562559
"name": "AZURE_OPENAI_API_VERSION",
@@ -2641,23 +2644,9 @@
26412644
}
26422645
},
26432646
"dependsOn": [
2644-
"[resourceId('Microsoft.Insights/components', parameters('ApplicationInsightsName'))]",
26452647
"[resourceId('Microsoft.Web/serverfarms', parameters('HostingPlanName'))]"
26462648
]
26472649
},
2648-
{
2649-
"type": "Microsoft.Insights/components",
2650-
"apiVersion": "2020-02-02",
2651-
"name": "[parameters('ApplicationInsightsName')]",
2652-
"location": "[resourceGroup().location]",
2653-
"tags": {
2654-
"[format('hidden-link:{0}', resourceId('Microsoft.Web/sites', parameters('ApplicationInsightsName')))]": "Resource"
2655-
},
2656-
"properties": {
2657-
"Application_Type": "web"
2658-
},
2659-
"kind": "web"
2660-
},
26612650
{
26622651
"type": "Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments",
26632652
"apiVersion": "2022-05-15",
@@ -2671,7 +2660,13 @@
26712660
"[resourceId('Microsoft.Web/sites', parameters('WebsiteName'))]"
26722661
]
26732662
}
2674-
]
2663+
],
2664+
"outputs": {
2665+
"webAppUrl": {
2666+
"type": "string",
2667+
"value": "[format('https://{0}.azurewebsites.net', parameters('WebsiteName'))]"
2668+
}
2669+
}
26752670
}
26762671
},
26772672
"dependsOn": [
@@ -2681,5 +2676,11 @@
26812676
"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_sql_db')]"
26822677
]
26832678
}
2684-
]
2679+
],
2680+
"outputs": {
2681+
"WEB_APP_URL": {
2682+
"type": "string",
2683+
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_app_service'), '2022-09-01').outputs.webAppUrl.value]"
2684+
}
2685+
}
26852686
}

0 commit comments

Comments
 (0)