Skip to content

Commit 179ea69

Browse files
Add diagnostic setting to Azure Front Door bicep module
Resolves #89
1 parent 2b049c1 commit 179ea69

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

infrastructure/afd-apim-pe/main.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ module afdModule '../../shared/bicep/modules/afd/v1/afd.bicep' = {
292292
fdeName: afdEndpointName
293293
afdSku: 'Premium_AzureFrontDoor'
294294
apimName: apimName
295+
logAnalyticsWorkspaceId: lawId
295296
}
296297
dependsOn: [
297298
apimModule

shared/bicep/modules/afd/v1/afd.bicep

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ param afdSku string = 'Premium_AzureFrontDoor'
2727
@description('The name of the API Management instance. Defaults to "apim-<resourceSuffix>".')
2828
param apimName string = 'apim-${resourceSuffix}'
2929

30+
@description('Log Analytics Workspace ID for diagnostic settings (optional)')
31+
param logAnalyticsWorkspaceId string = ''
32+
3033

3134
// ------------------------------
3235
// RESOURCES
@@ -175,6 +178,35 @@ resource securityPolicy 'Microsoft.Cdn/profiles/securityPolicies@2025-04-15' = {
175178
}
176179
}
177180

181+
// https://learn.microsoft.com/azure/templates/microsoft.insights/diagnosticsettings
182+
resource frontDoorDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (!empty(logAnalyticsWorkspaceId)) {
183+
name: 'afd-diagnostics'
184+
scope: frontDoorProfile
185+
properties: {
186+
workspaceId: logAnalyticsWorkspaceId
187+
logs: [
188+
{
189+
categoryGroup: 'allLogs'
190+
enabled: true
191+
retentionPolicy: {
192+
enabled: false
193+
days: 0
194+
}
195+
}
196+
]
197+
metrics: [
198+
{
199+
category: 'AllMetrics'
200+
enabled: true
201+
retentionPolicy: {
202+
enabled: false
203+
days: 0
204+
}
205+
}
206+
]
207+
}
208+
}
209+
178210

179211
// ------------------------------
180212
// OUTPUTS

0 commit comments

Comments
 (0)