Actionable Data Analytics
Join Our Email List for Data News Sent to Your Inbox

Executing Azure Synapse Analytics Pipelines With Azure Logic Apps

As powerful as Synapse Analytics is on its own, adding Azure Logic Apps to the mix unlocks even more potential. You can easily execute Azure Synapse Analytics Pipelines with Azure Logic Apps. This is especially useful for adding some of Azure Synapse Analytics’ capabilities to more traditional integration solutions.

 

Before you start, make sure you have the following pre-requisites:

  • An Azure subscription
  • A Synapse Analytics workspace
  • A Synapse Analytics pipeline created in your workspace
  • An Azure Logic App created in your subscription
    • For this example, I will be using the consumption model of Azure Logic Apps and the Azure Portal. You can use Visual Studio or Visual Studio Code as well
  • Enable managed identity for Azure Logic Apps
  • Give Azure Logic Apps access to Synapse

Download the solution

To download the solution, visit my GitHub repository.

Download here

Enable managed identity for Azure Logic Apps

In your Azure Logic Apps, enabled managed identity.

Give Azure Logic Apps access to Synapse

In Azure Synapse Analytics, grant access to the Azure Logic Apps.

 

Create the Azure Logic Apps Solution

Let’s create the solution for Executing Azure Synapse Analytics Pipelines With Azure Logic Apps. 

First, navigate to your Azure Logic Apps. Then, select blank canvas, or in my case, I want to trigger the Azure Logic Apps when an HTTP request is received.

I am my case; I am going to include the pipeline name as part of the HTTP request.

{
    “properties”: {
        “PipelineName”: {
            “type”“string”
        },
        “SynapseName”: {
            “type”“string”
        }
    },
    “type”“object”
}
 
Secondly, select the HTTP request activity and then the HTTP action.
 
 
Configure the HTTP action as follows:
 
 
 
At this stage, the solution will execute the Azure Synapse Analytics pipeline asynchronously, so you will not know the final status of the pipeline.
 
 
The following section includes the steps for validating if the pipeline has been executed correctly.
 

Check Azure Synapse Analytics Pipeline Status

The following steps will help define some variables:
  1. Parse response from the previous step to get the the runId (required for identifying the status of the pipeline)
    1. {
          “properties”: {
              “runId”: {
                  “type”: “string”
              }
          },
          “type”: “object”
      }
  2. Initialize Variable Action: Create a variable to store the status of the pipeline
  3. Initialize Variable Action: Create a variable to stop checking the status if the pipeline is taking too long
  4. Condition Control Action: To validate if the pipeline has finished
    1. the @or(not(equals(variables(‘PipelineStatus’), ”)),equals(variables(‘ExitIfTakingTooLong’), 0))
  5. Delay Action: modify the seconds between attempts to check status
  6. HTTP Action: Check the status of the pipeline
    1. GETthe 
    2. https://@the {triggerBody()?[‘SynapseName’]}.dev.azuresynapse.net/pipelineruns/@{body(‘Parse_JSON’)?[‘runId’]}?api-version=2020-12-01
    3. Content-Type: application/json
    4. Auth Type: Managed Identity
    5. Audience: httIdentity.azuresynaIdentity
  7. Parse JSON Action: Parse Status Response
    {
        “properties”: {
            “annotations”: {
                “type”: “array”
            },
            “debugRunId”: {},
            “durationInMs”: {},
            “id”: {
                “type”: “string”
            },
            “invokedBy”: {
                “properties”: {
                    “id”: {
                        “type”: “string”
                    },
                    “invokedByType”: {
                        “type”: “string”
                    },
                    “name”: {
                        “type”: “string”
                    }
                },
                “type”: “object”
            },
            “isLatest”: {
                “type”: “boolean”
            },
            “lastUpdated”: {
                “type”: “string”
            },
            “message”: {
                “type”: “string”
            },
            “parameters”: {
                “properties”: {},
                “type”: “object”
            },
            “pipelineName”: {
                “type”: “string”
            },
            “returnValue”: {},
            “runDimension”: {
                “properties”: {},
                “type”: “object”
            },
            “runEnd”: {},
            “runGroupId”: {
                “type”: “string”
            },
            “runId”: {
                “type”: “string”
            },
            “runStart”: {
                “type”: “string”
            },
            “status”: {
                “type”: “string”
            }
        },
        “type”: “object”
    }
     
  8. Set Variable Action: Update status variable
  9. Decrement Variable Action: reduce attempts variable
  10. Check final status

Testing the Solution

To test the solution, execute by passing the correct body parameters.

 
 
Add the body.
{
    “SynapseName”“syn-ada-dev-aue”,
   “PipelineName”“Test”            
}
 

In Azure Synapse Analytics, you will see the pipeline being executed.

 

In Azure Logic Apps, execute the output.

 

You could also store the Azure Synapse Analytics name in an Azure Key Vault to make it easy to deploy between environments.

Conclusion

In conclusion, Azure Logic Apps can be a great asset when managing Azure Synapse Analytics, from design to execution, it helps ensure that everything runs smoothly.

Overall, the two tools can be used together to get the most out of Azure Synapse Analytics and automate the execution of pipelines within Azure Logic Apps.

comment [ 1 ]
share
No tags 0
1 Response
  • David
    19 . 04 . 2024

    Thanks for the awesome write up and even the template in git hub, exactly what I needed. One note I had to provide the service principal “Synapse Credential User Permissions” to get it to authenticate. Otherwise, the template was spot on, and I love the addition of a way to wait to ensure the pipeline completes. For us the next step is to refresh a Semantic Model, but the Sybnape pipelines run at different speeds, and this was a simple solution. Thanks!

Do you want to leave a comment?

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.