How to start a existing trigger in adf programmatically, using Python? or any best solution?

Rajesh Gopisetti 5 Reputation points
2023-08-11T09:03:19.0566667+00:00

How to start a existing trigger in adf programmatically. When i am creating trigger thru code it is in stopped status. I tried patch as well as begin_start and both are not working here. I used patch with runtime State to Started with REST API it is not working and begin_start also not working. I also tried start?api in url and post method also not working. Please help me in this.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,529 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,261 Reputation points
    2023-08-11T16:40:52.9266667+00:00

    Hello @Rajesh Gopisetti Welcome to QnA forum,

    What programming language are you using here? Any sample code snippets or any documentation you have followed?
    Please add screenshots of your trigger logs if they are available? any error logs? either form your code execution or from Azure portal?

    Any Firewall issues?

    Is this intermittent issue?

    Any API version issue?
    What is the Trigger Type?

    Azure Region?

    def main():
    
        # Azure subscription ID
        subscription_id = '597e'  
        rg_name = 'MyRG'
    
        df_name = 'msce'
    
        # Specify your Active Directory client ID, client secret, and tenant ID
        credentials = ClientSecretCredential(client_id='1f52', client_secret='2i', tenant_id='c8') 
        resource_client = ResourceManagementClient(credentials, subscription_id)
        adf_client = DataFactoryManagementClient(credentials, subscription_id)
    
    # Create a trigger
       
        adf_client.triggers.create_or_update(  resource_group_name="MyRG",
            factory_name="msftCommunityspace",
            trigger_name="ETFTrigger",
            trigger={
                "properties": {
                    "pipelines": [
                        {
                            # "parameters": {"OutputBlobNameList": ["exampleoutput.csv"]},
                            "pipelineReference": {"referenceName": "MonitorPipelineTriggers", "type": "PipelineReference"},
                        }
                    ],
                    "type": "ScheduleTrigger",
                    "typeProperties": {
                        "recurrence": {
                            "endTime": "2018-06-16T00:55:13.8441801Z",
                            "frequency": "Minute",
                            "interval": 4,
                            "startTime": "2018-06-16T00:39:13.8441801Z",
                            "timeZone": "UTC",
                        }
                    },
                }
            },)
    #  Start A Trigger
        adf_client.triggers.begin_start(
            resource_group_name="MyRG",
            factory_name="mse",
            trigger_name="ETFTrigger",
        ).result()
    # Start the trigger
    # adf_client.triggers.start(rg_name, df_name, tr_name)
    
    # Start the main method
    main()
    

    The trigger will be created and published, you may try to edit the trigger from the portal and you may see the publish option. But the above script creates the trigger and publishes.User's image

    If the response is helpful, please click "Accept Answer" and Click 'Yes' (For Short Survey). So that we can close this case.


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.