Skip to content

Commit

Permalink
Merge pull request #76 from pamelafox/appdiagnostics
Browse files Browse the repository at this point in the history
Adding app diagnostics
  • Loading branch information
pamelafox committed Apr 10, 2024
2 parents aa0a2a8 + eb0504e commit 4d48728
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
56 changes: 56 additions & 0 deletions infra/core/host/app-diagnostics.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
param appName string = ''

@description('The kind of the app.')
@allowed([
'functionapp'
'webapp'
])
param kind string

@description('Resource ID of log analytics workspace.')
param diagnosticWorkspaceId string

param diagnosticLogCategoriesToEnable array = kind == 'functionapp' ? [
'FunctionAppLogs'
] : [
'AppServiceHTTPLogs'
'AppServiceConsoleLogs'
'AppServiceAppLogs'
'AppServiceAuditLogs'
'AppServiceIPSecAuditLogs'
'AppServicePlatformLogs'
]

@description('Optional. The name of metrics that will be streamed.')
@allowed([
'AllMetrics'
])
param diagnosticMetricsToEnable array = [
'AllMetrics'
]


var diagnosticsLogs = [for category in diagnosticLogCategoriesToEnable: {
category: category
enabled: true
}]

var diagnosticsMetrics = [for metric in diagnosticMetricsToEnable: {
category: metric
timeGrain: null
enabled: true
}]

resource app 'Microsoft.Web/sites@2022-03-01' existing = {
name: appName
}

resource app_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: '${appName}-diagnostics'
scope: app
properties: {
workspaceId: diagnosticWorkspaceId
metrics: diagnosticsMetrics
logs: diagnosticsLogs
}
}
11 changes: 11 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ module functionApp 'core/host/functions.bicep' = {
}
}


module diagnostics 'core/host/app-diagnostics.bicep' = {
name: '${prefix}-appdiagnostics'
scope: resourceGroup
params: {
appName: functionApp.outputs.name
kind: 'functionapp'
diagnosticWorkspaceId: monitoring.outputs.logAnalyticsWorkspaceId
}
}

// CDN in front
module cdnProfile 'cdn-profile.bicep' = {
name: 'cdn-profile'
Expand Down

0 comments on commit 4d48728

Please sign in to comment.