Hello , Welcome to MS Q&A
The error message "Data sink is already used in diagnostic setting for category 'WorkflowRuntime'" indicates that the same data sink cannot be reused in different diagnostic settings for the same category within the same Logic App. This is a common issue when redeploying Logic Apps with diagnostic settings using Bicep templates.
To resolve this issue, you need to ensure that your Bicep template does not attempt to create duplicate diagnostic settings. You can use conditional logic in your Bicep template to check if the diagnostic settings already exist and only create them if they do not.
Here is an example of how you can modify your Bicep template to include diagnostic settings conditionally:
resource logicApp 'Microsoft.Logic/workflows@2019-05-01' = {
name: 'your-logic-app-name'
location: resourceGroup().location
properties: {
definition: loadTextContent('logicapp-definition.json')
parameters: {}
}
}
resource diagnosticSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (empty(diagnosticSetting)) {
name: 'logicapp-Diag'
properties: {
logs: [
{
category: 'WorkflowRuntime'
enabled: true
retentionPolicy: {
days: 0
enabled: false
}
}
]
workspaceId: 'your-log-analytics-workspace-id'
}
}
References:
- Monitor and collect diagnostic data for workflows in Azure Logic Apps
- Troubleshoot and diagnose workflow failures in Azure Logic Apps
- Sink transformation in mapping data flow
Kindly accept answer if it helps
Please let us know if any questions
Thanks
Deepanshu