Azure Function App Diagnostic Settings #8435
Answered
by
kevball2
rebuildtech
asked this question in
Q&A
-
Hi Team Is there a way in Bicep to enable Function app Diagnostic Settings and link it to the log analytics workspace that's getting created with insights in BICEP I see Microsoft.web/sites/diagnostic However this seems to be referring to existing one itself. Can someone help me on this if possible? |
Beta Was this translation helpful? Give feedback.
Answered by
kevball2
Sep 20, 2022
Replies: 1 comment 2 replies
-
You can using something like this @description('Optional. 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
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]
var diagnosticsMetrics = [for metric in diagnosticMetricsToEnable: {
category: metric
timeGrain: null
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]
resource app_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagnosticSettingsName
properties: {
workspaceId: diagnosticWorkspaceId
metrics: diagnosticsMetrics
logs: diagnosticsLogs
}
scope: app
}
The diagnostics scope is tied to your function app you are creating. Just replace app with the name of your function app resource |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
brwilkinson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can using something like this