gpt4 book ai didi

c# - 如何从 C# 代码调用 Azure 数据工厂管道?

转载 作者:行者123 更新时间:2023-12-02 07:33:38 24 4
gpt4 key购买 nike

我需要一些从 C# 代码调用 ADF(Azure 数据工厂)作业的想法。如果您可以分享一些实现此功能的示例,那将会非常有帮助。

感谢您查看我的帖子。

最佳答案

安装最新版本的 Microsoft.Azure.Management.DataFactory NuGet 包。然后您可以像这样触发 ADF 管道:

private DataFactoryManagementClient CreateClient(string subscriptionId, string tenantId)
{
// AzureServiceTokenProvider uses developer credentials when running locally
// and uses managed identity when deployed to Azure.
// If getting an exception when running locally, run "az login" command in Azure CLI
var provider = new AzureServiceTokenProvider();
var token = provider.GetAccessTokenAsync("https://management.azure.com", tenantId).Result;
ServiceClientCredentials credentials = new TokenCredentials(token);

DataFactoryManagementClient client = new DataFactoryManagementClient(credentials);
client.SubscriptionId = subscriptionId;
return client;
}

public async Task<string> TriggerPipeline(string pipelineName, IDictionary<string, object> parameters)
{
var run = await client.Pipelines.CreateRunWithHttpMessagesAsync(resourceGroupName, dataFactoryName, pipelineName, parameters: parameters);
return run.Body.RunId;
}

关于c# - 如何从 C# 代码调用 Azure 数据工厂管道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64865235/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com