简体   繁体   中英

.net Core : How to pass parameters and run Azure data factory pipeline from C# Code?

I am using Microsoft.Azure.Management.DataFactories .net core package.

I am using following code to get the required token for accessing azure data factory pipeline in C# .net core:

public static void RunDataFactoryPipeline()
    {
        try
        {
            var context = new AuthenticationContext("" + "");
            var credentials = new ClientCredential(clientId: "", clientSecret: "");
            AuthenticationResult result = context.AcquireTokenAsync("", credentials).Result;

            if (result == null)
            {
                throw new InvalidOperationException("Failed to acquire Token");
            }

            var token = result.AccessToken;
            var serviceClientCredentials = new TokenCloudCredentials("",result.AccessToken);
            var client = new DataFactoryManagementClient(serviceClientCredentials);

            StartPipeline("name", "name", "name", client);
        }
        catch (Exception ex)
        {
            throw;
        }
    }
public static void StartPipeline(string resourceGroup, string dataFactory, string pipeLineName, DataFactoryManagementClient client, )
        {
            var pipeLine = client.Pipelines.Get(resourceGroup, dataFactory, pipeLineName);
}

But i don't find any method using which i can run the pipeline in factory.

Seems you are using incorrect nuget package, use this one and you should have methods available to run pipelines on the IPipelineOperations instance

Install-Package Microsoft.Azure.Management.DataFactory -Version 4.7.0

public static void StartPipeline(string resourceGroup, string dataFactory, string pipeLineName, DataFactoryManagementClient client )
{
   var pipeLine = client.Pipelines.Get(resourceGroup, dataFactory, pipeLineName);
   client.Pipelines.CreateRun(resourceGroup, dataFactory, pipeLineName);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM