本文介绍了.net Core:如何从 C# 代码传递参数和运行 Azure 数据工厂管道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Microsoft.Azure.Management.DataFactories .net 核心包.
我正在使用以下代码获取访问 C# .net 核心中 azure 数据工厂管道所需的令牌:
public static void RunDataFactoryPipeline(){尝试{var context = new AuthenticationContext("" + "");var 凭证 = 新的 ClientCredential(clientId: "", clientSecret: "");AuthenticationResult 结果 = context.AcquireTokenAsync("", credentials).Result;如果(结果 == 空){throw new InvalidOperationException("获取令牌失败");}var token = result.AccessToken;var serviceClientCredentials = new TokenCloudCredentials("",result.AccessToken);var client = new DataFactoryManagementClient(serviceClientCredentials);StartPipeline("name", "name", "name", client);}捕获(异常前){扔;}}public static void StartPipeline(string resourceGroup, string dataFactory, string pipeLineName, DataFactoryManagementClient client, ){var pipeLine = client.Pipelines.Get(resourceGroup, dataFactory, pipeLineName);}
但是我没有找到任何可以在其中运行管道的方法工厂.
解决方案
似乎您使用了不正确的 nuget 包,使用这个包,您应该有方法可用于在 IPipelineOperations 实例上运行管道
安装包 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);}
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);
}
解决方案
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);
}
这篇关于.net Core:如何从 C# 代码传递参数和运行 Azure 数据工厂管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!