Currently our diagnostic settings look somewhat like this:
resource publicIpAddress_diagnosticSettings 'Microsoft.Insights/diagnosticsettings@2021-05-01-preview' = if ((!empty(diagnosticStorageAccountId)) || (!empty(workspaceId)) || (!empty(eventHubAuthorizationRuleId)) || (!empty(eventHubName))) {
name: '${publicIpAddress.name}-diagnosticSettings'
properties: {
storageAccountId: (empty(diagnosticStorageAccountId) ? json('null') : diagnosticStorageAccountId)
workspaceId: (empty(workspaceId) ? json('null') : workspaceId)
eventHubAuthorizationRuleId: (empty(eventHubAuthorizationRuleId) ? json('null') : eventHubAuthorizationRuleId)
eventHubName: (empty(eventHubName) ? json('null') : eventHubName)
metrics: ((empty(diagnosticStorageAccountId) && empty(workspaceId) && empty(eventHubAuthorizationRuleId) && empty(eventHubName)) ? json('null') : diagnosticsMetrics)
logs: ((empty(diagnosticStorageAccountId) && empty(workspaceId) && empty(eventHubAuthorizationRuleId) && empty(eventHubName)) ? json('null') : diagnosticsLogs)
}
scope: publicIpAddress
}
it begs the question if it would not already work to just use:
resource publicIpAddress_diagnosticSettings 'Microsoft.Insights/diagnosticsettings@2021-05-01-preview' = if ((!empty(diagnosticStorageAccountId)) || (!empty(workspaceId)) || (!empty(eventHubAuthorizationRuleId)) || (!empty(eventHubName))) {
name: '${publicIpAddress.name}-diagnosticSettings'
properties: {
storageAccountId: (empty(diagnosticStorageAccountId) ? diagnosticStorageAccountId : null
workspaceId: (empty(workspaceId) ? workspaceId : null
eventHubAuthorizationRuleId: !empty(eventHubAuthorizationRuleId ? eventHubAuthorizationRuleId : null
eventHubName: empty(eventHubName) ? eventHubName : null
metrics: diagnosticsMetrics
logs: diagnosticsLogs
}
scope: publicIpAddress
}
Currently our diagnostic settings look somewhat like this:
it begs the question if it would not already work to just use: