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

标签 c# azure azure-data-factory

我需要一些从 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/

相关文章:

c# - 具有分层对象的 MVVM 的引用实现

c# - 为什么使用格式字符串 "1212012"调用 DateTime.TryParseExact 会因输入 "Mddyyyy"而失败

json - Azure - 地理搜索 - 返回距离

azure - 等待事件中的等待时间可以是可变的吗?

azure - 从 ADF 中的文件名中提取文本

c# - 使用 OWIN 的网络套接字

c# - 如何在 Excel 中保留 Excel 功能区加载项的数据

Azure 中的 API 安全最佳实践

c# - 使用 C# 创建控制台应用程序以从 Azure 表存储读取数据

azure - 如何使用 Azure 数据工厂 v2 在 Azure SQL 数据库的所有表中更新插入/插入记录