Require arm template to start and stop synapse pipeline triggers while deploying the artifacts in CI CD.

Polamuri Krishna Chandra 10 Reputation points
2024-07-23T19:43:38.7966667+00:00

Hi, I need arm template to start and stop synapse pipeline triggers while deploying the artifacts in CI CD.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,378 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 33,866 Reputation points Volunteer Moderator
    2024-07-23T21:28:04.6166667+00:00
    
    {
    
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    
      "contentVersion": "1.0.0.0",
    
      "resources": [
    
        {
    
          "type": "Microsoft.Synapse/workspaces/triggers",
    
          "apiVersion": "2021-06-01-preview",
    
          "name": "[concat(parameters('workspaceName'), '/', parameters('triggerName'))]",
    
          "properties": {
    
            "runtimeState": "[parameters('triggerState')]"
    
          }
    
        }
    
      ],
    
      "parameters": {
    
        "workspaceName": {
    
          "type": "string",
    
          "metadata": {
    
            "description": "The name of the Synapse workspace"
    
          }
    
        },
    
        "triggerName": {
    
          "type": "string",
    
          "metadata": {
    
            "description": "The name of the Synapse pipeline trigger"
    
          }
    
        },
    
        "triggerState": {
    
          "type": "string",
    
          "allowedValues": [
    
            "Started",
    
            "Stopped"
    
          ],
    
          "metadata": {
    
            "description": "The desired state of the Synapse pipeline trigger"
    
          }
    
        }
    
      }
    
    }
    
    

    Explanation

    To usethis template in your CI/CD pipeline, you will need to provide the necessary parameters (workspaceName, triggerName, and triggerState) during the deployment process. You can integrate it with Azure DevOps or GitHub Actions.

    This is how you can call this template using Azure CLI:

    
    az deployment group create --resource-group <ResourceGroupName> \
    
      --template-file <TemplateFilePath> \
    
      --parameters workspaceName=<WorkspaceName> triggerName=<TriggerName> triggerState=<TriggerState>
    

    In your CI/CD pipeline, you can add steps to first stop the triggers before deploying your artifacts and then start the triggers again after deployment.

    
    - stage: Deploy
    
      jobs:
    
        - job: DeployArtifacts
    
          steps:
    
            - task: AzureCLI@2
    
              inputs:
    
                azureSubscription: 'AzureSubscription'
    
                scriptType: 'bash'
    
                scriptLocation: 'inlineScript'
    
                inlineScript: |
    
                  az deployment group create --resource-group <ResourceGroupName> --template-file stopTriggerTemplate.json --parameters workspaceName=<WorkspaceName> triggerName=<TriggerName> triggerState=Stopped
    
            # Add steps to deploy your artifacts here
    
            - task: AzureCLI@2
    
              inputs:
    
                azureSubscription: 'AzureSubscription'
    
                scriptType: 'bash'
    
                scriptLocation: 'inlineScript'
    
                inlineScript: |
    
                  az deployment group create --resource-group <ResourceGroupName> --template-file startTriggerTemplate.json --parameters workspaceName=<WorkspaceName> triggerName=<TriggerName> triggerState=Started
    
    

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.