Deploy of bicep Template with Logic Apps throws Error : Data sinks can’t be reused in different settings on the same category for the same resource

Srikanth Vanam (PERSISTENT SYSTEMS LIMITED) 0 Reputation points Microsoft Vendor
2024-08-27T05:46:28.89+00:00

Hi, we are trying to redeploy existing logic app using bicep template. This Logic app is already configured with Diagnostics Settings manually. I have automated the enabling of diagnostics settings along with the Logic app resource using bicep.

However, when I run the bicep template, it is throwing the following error

Data sink 
is already used in diagnostic setting ' logicapp-Diag' for category 'WorkflowRuntime'. Data sinks can't be reused in different settings on the same category for the same resource
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,187 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshukatara-6769 10,130 Reputation points
    2024-08-27T05:54:20.0866667+00:00

    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:

    Kindly accept answer if it helps

    Please let us know if any questions

    Thanks
    Deepanshu


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.