Bicep Module for Creating Diagnostic Settings for Different Azure Resources

Taranjeet Malik 496 Reputation points
2024-07-31T01:08:38.6833333+00:00

Hi

I would like to create a module to enable Diagnostics Settings for various Azure resources. The idea is to be able to pass the resource type that can be accepted by the "scope" property within the module definition (Microsoft.Insights/diagnosticSettings--> https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/diagnosticsettings?pivots=deployment-language-bicep#resource-format). However, Bicep doesn't allows defining a parameter type (other than the standard such as String, SecureString, Object etc.) that can hold the type of a resource. If I try and define this property as "String" within the module, VS Code starts complaining this:

The property "scope" expected a value of type "resource | tenant" but the provided value is of type "string".

I'm sure this is a common ask and there must be a way around it....can someone please share other possible approach to this?

Thanks

Taranjeet Singh

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,054 questions
0 comments No comments
{count} votes