Generated ADF pipelibe using Python

CON-Thirusenthilkumar Pandiyan 45 Reputation points
2023-09-19T11:17:33.5466667+00:00

Hello,

I am working on the dynamic data pipeline framework were i can generate Azure data pipeline programatically. till now, i have done for creating copy activiyt and dataflow. the final step is, need to link between this two by creating another pipeline. for ex: dataflow(reads config info from database) and copy activity perform based on the config.

Kindly help, how to create new pipeline by attaching dataflow and copyactivity

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

Accepted answer
  1. Amira Bedhiafi 24,556 Reputation points
    2023-09-19T16:28:35.19+00:00

    You'll first need to have the azure-mgmt-datafactory package installed. Install it using pip if you haven't:

         pip install azure-mgmt-datafactory
    

    Then you will need to authenticate against the Azure subscription where your Data Factory resides.

       from azure.identity import DefaultAzureCredential
       from azure.mgmt.datafactory import DataFactoryManagementClient
       resource_group_name = "your-resource-group-name"
       data_factory_name = "your-data-factory-name"
       location = "your-location"
       subscription_id = "your-subscription-id"
       # Authenticate
       credential = DefaultAzureCredential()
       adf_client = DataFactoryManagementClient(credential, subscription_id)
    

    After initializing, you can start defining the pipeline with linked Dataflow and Copy Activity.

       from azure.mgmt.datafactory.models import PipelineResource, CopyActivity, DataFlow
       # Define the Dataflow (replace with your actual Dataflow details)
       dataflow = DataFlow(
           name="your-dataflow-name",
           description="Your Dataflow description",
           folder="Path/to/your/Dataflow"
           # Add other necessary configurations
       )
       # Define the Copy Activity (replace with your actual Copy Activity details)
       copy_activity = CopyActivity(
           name="your-copy-activity-name",
           description="Your Copy Activity description",
           # Add other necessary configurations
       )
       # Create the Pipeline with the above Dataflow and Copy Activity linked
       pipeline = PipelineResource(
           activities=[dataflow, copy_activity],
           description="Your pipeline description"
       )
       # Create the pipeline in Azure Data Factory
       adf_client.pipelines.create_or_update(resource_group_name, data_factory_name, "your-pipeline-name", pipeline)
    

    Try to update the code to adjust it to your needs.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.