I need some ideas for invoking an ADF (Azure Data Factory) job from C# code. If you can share some examples implementing this, it will really be helpful.
Thank you for looking into my post.
Install the latest version of the Microsoft.Azure.Management.DataFactory
NuGet package. Then you can trigger an ADF pipeline like this:
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;
}