0
votes

I'm trying to access Azure Data Fabric V2 programmatically.

First, I had created an App Registration in Azure portal and a Client secret. Then I gave Contributor permission to this App registration on the entire suscription, and also in the resource group where my data factory lives. Using this credentials I'm able to login to the portal and create an DataFactoryManagementClient

private void CreateAdfClient()
{
    var authenticationContext = new AuthenticationContext($"https://login.windows.net/{tenantId}");
    var credential = new ClientCredential(clientId: appRegistrationClientId, clientSecret: appRegistrationClientkey);
    var result = authenticationContext.AcquireTokenAsync(resource: "https://management.core.windows.net/", clientCredential: credential).ConfigureAwait(false).GetAwaiter().GetResult();

    if (result == null)
    {
        throw new InvalidOperationException("Failed to obtain the JWT token");
    }

    var token = result.AccessToken;

    var tokenCloudCredentials = new TokenCloudCredentials(subscriptionId, token);
    datafactoryClient = new DataFactoryManagementClient(tokenCloudCredentials);
}

However, when I try to get my pipeline with

var pipeline = datafactoryClient.Pipelines.Get(resourceGroup, dataFactory, pipelineName);

it throws an error:

System.Private.CoreLib: Exception while executing function: StartRawMeasuresSync. Microsoft.Azure.Management.DataFactories: ResourceNotFound: The Resource 'Microsoft.DataFactory/dataFactories/MyPipeline' under resource group 'MyResGroup' was not found.

I had verified that the resource group, the data factory name and the pipeline name are correct, but it keeps throwing this error.

1

1 Answers

0
votes

I had the same issue, and it was due to referencing the Nuget package for Azure Data Factory v1 instead of v2.

  • Version 1: Microsoft.Azure.Management.DataFactories
  • Version 2: Microsoft.Azure.Management.DataFactory