Suraj
Suraj

Reputation: 3

Not able to run Azure Data Factory Pipeline using Visual Studio 2015

I have followed the Azure documentation steps to create a simple Copy Data Factory from Blob to SQL.

Now I want to run the pipeline through VS code. I have checked the authentication keys and Roles assigned are correct.

Below is the code -

var context = new AuthenticationContext("https://login.windows.net/" + tenantID);
ClientCredential cc = new ClientCredential(applicationId, authenticationKey);
AuthenticationResult result = context.AcquireTokenAsync("https://management.azure.com/", cc).Result;
ServiceClientCredentials cred = new TokenCredentials(result.AccessToken);
var client = new DataFactoryManagementClient(cred) { SubscriptionId = subscriptionId };

Console.WriteLine("Creating pipeline run...");
var st = client.Pipelines.Get(resourceGroup, dataFactoryName, pipelineName);
CreateRunResponse runResponse = client.Pipelines.CreateRunWithHttpMessagesAsync(resourceGroup, dataFactoryName, pipelineName).Result.Body;
Console.WriteLine("Pipeline run ID: " + runResponse.RunId);

However, I get Forbidden error.

The client 'xxxx' with object id 'xxxx' does not have authorization to perform action 'Microsoft.DataFactory/factories/pipelines/read' over scope '/subscriptions/xxxxx/resourceGroups/'

How can I fix this?

Upvotes: 0

Views: 1205

Answers (1)

Tom Sun
Tom Sun

Reputation: 24569

How can I fix this?

According to the exception message that it indicates that you don't assign the corresponding role to application to access the data factory.

I test your code with Azure Datafactory(V2) on my side , it works correctly. The following is my details steps.

  1. Registry an Azure AD WebApp application.

  2. Get the clientId and clientscret from created Application.

  3. Assign the role the application to access the datafactory.

enter image description here

  1. Test code on my side.

    enter image description here

Upvotes: 1

Related Questions