Skip to content

Commit

Permalink
Set logging configuration in App Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Oct 7, 2023
1 parent 8c2d3c8 commit b39bdf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ resource providedLogAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces
resource appEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = if (!hasProvidedAppEnvironment) {
name: name
location: location
properties: {}
properties: {
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: hasProvidedLogAnalyticsWorkspace ? providedLogAnalyticsWorkspace.properties.customerId : logAnalyticsWorkspace.properties.customerId
sharedKey: hasProvidedLogAnalyticsWorkspace ? providedLogAnalyticsWorkspace.listKeys().primarySharedKey : logAnalyticsWorkspace.listKeys().primarySharedKey
}
}
}
}

/* Application Insights */
Expand Down
13 changes: 12 additions & 1 deletion main.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,18 @@
"apiVersion": "2023-05-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"properties": {}
"properties": {
"appLogsConfiguration": {
"destination": "log-analytics",
"logAnalyticsConfiguration": {
"customerId": "[if(variables('hasProvidedLogAnalyticsWorkspace'), reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('logAnalyticsWorkspaceId'), '/')[2], split(parameters('logAnalyticsWorkspaceId'), '/')[4]), 'Microsoft.OperationalInsights/workspaces', split(parameters('logAnalyticsWorkspaceId'), '/')[8]), '2022-10-01').customerId, reference(resourceId('Microsoft.OperationalInsights/workspaces', parameters('name')), '2022-10-01').customerId)]",
"sharedKey": "[if(variables('hasProvidedLogAnalyticsWorkspace'), listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('logAnalyticsWorkspaceId'), '/')[2], split(parameters('logAnalyticsWorkspaceId'), '/')[4]), 'Microsoft.OperationalInsights/workspaces', split(parameters('logAnalyticsWorkspaceId'), '/')[8]), '2022-10-01').primarySharedKey, listKeys(resourceId('Microsoft.OperationalInsights/workspaces', parameters('name')), '2022-10-01').primarySharedKey)]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', parameters('name'))]"
]
},
{
"type": "Microsoft.Insights/components",
Expand Down

0 comments on commit b39bdf0

Please sign in to comment.