How to connect ADX cluster query with the logic app

Saransh Gaur 40 Reputation points Microsoft Employee
2024-06-06T15:23:52.0966667+00:00

Trying to do the following things, one after another:

  • Schedular to run in 6 hours
  • Trigger ADX cluster query
  • For the array output string, trigger email for each element of array.

I found out that this can be done through logic app. Can someone help me out how to do it.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,011 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 18,636 Reputation points
    2024-06-17T04:35:41.9766667+00:00

    @Saransh Gaur Thanks for your question. You can use Recurrence trigger to specify how frequently the logic app should be executed. To trigger ADX cluster query, you can use existing ADX connector actions.

    Here is sample logic app code for your reference

    User's image

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "For_each": {
                    "actions": {
                        "Compose": {
                            "inputs": "@items('For_each')",
                            "type": "Compose"
                        },
                        "Send_an_email_(V2)": {
                            "inputs": {
                                "body": {
                                    "Body": "<p>@{outputs('Compose')}</p>",
                                    "Importance": "Normal",
                                    "Subject": "Test",
                                    "To": "xxxxx@microsoft.com"
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['office365']['connectionId']"
                                    }
                                },
                                "method": "post",
                                "path": "/v2/Mail"
                            },
                            "runAfter": {
                                "Compose": [
                                    "Succeeded"
                                ]
                            },
                            "type": "ApiConnection"
                        }
                    },
                    "foreach": "@body('Run_KQL_query')?['value']",
                    "runAfter": {
                        "Initialize_variable": [
                            "Succeeded"
                        ]
                    },
                    "type": "Foreach"
                },
                "Initialize_variable": {
                    "inputs": {
                        "variables": [
                            {
                                "name": "Count",
                                "type": "integer",
                                "value": 0
                            }
                        ]
                    },
                    "runAfter": {
                        "Run_KQL_query": [
                            "Succeeded"
                        ]
                    },
                    "type": "InitializeVariable"
                },
                "Run_KQL_query": {
                    "inputs": {
                        "body": {
                            "cluster": "https://help.kusto.windows.net/",
                            "csl": "StormEvents \n| where StartTime between (datetime(2007-11-01) .. datetime(2007-12-01))\n| where State == \"FLORIDA\"  \n| take 2",
                            "db": "Samples"
                        },
                        "host": {
                            "connection": {
                                "name": "@parameters('$connections')['kusto']['connectionId']"
                            }
                        },
                        "method": "post",
                        "path": "/ListKustoResults/false"
                    },
                    "runAfter": {},
                    "type": "ApiConnection"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {
                "$connections": {
                    "defaultValue": {},
                    "type": "Object"
                }
            },
            "triggers": {
                "Recurrence": {
                    "evaluatedRecurrence": {
                        "frequency": "Month",
                        "interval": 3
                    },
                    "recurrence": {
                        "frequency": "Month",
                        "interval": 3
                    },
                    "type": "Recurrence"
                }
            }
        },
        "parameters": {
            "$connections": {
                "value": {
                    "kusto": {
                        "connectionId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Integration/providers/Microsoft.Web/connections/kusto",
                        "connectionName": "kusto",
                        "id": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    /providers/Microsoft.Web/locations/eastus/managedApis/kusto"
                    },
                    "office365": {
                        "connectionId": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    /resourceGroups/swdhanwa_Integration/providers/Microsoft.Web/connections/office365",
                        "connectionName": "office365",
                        "id": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    /providers/Microsoft.Web/locations/eastus/managedApis/office365"
                    }
                }
            }
        }
    }
    
    0 comments No comments