LearningToCode
LearningToCode

Reputation: 259

Get ADF Pipeline JSON from C#

I am trying to get the entire JSON of an ADF pipeline (both v1 & v2) from C#

I could see documents that provide details abut creating pipelines from C#, unfortunately I am not sure of the right method/endpoint to perform this operation in C#.

var client = new DataFactoryManagementClient(cred) { SubscriptionId = subscriptionId };

var factory = client.Factories.Get("", "");

var pipeline = client.Pipelines.Get("", "", "");


Unfortunately that doesn't provide me what am looking for, I believe the JSON are formatted as C# objects in factory and client

Am I right with the above statement ? Will I have all the JSON details in C# objects?

Upvotes: 1

Views: 1559

Answers (1)

Mohit Verma
Mohit Verma

Reputation: 5294

Azure Data factory exposes rest api and SDK which you can call for both V1 and V2 which gives you the pipeline result in json .

For example : Below api will give you the list of pipeline in json format for one Factory:

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines?api-version=2018-06-01

same set of operation you can do it using SDK too by using below method:

public static Microsoft.Rest.Azure.IPage<Microsoft.Azure.Management.DataFactory.Models.PipelineResource> ListByFactory (this Microsoft.Azure.Management.DataFactory.IPipelinesOperations operations, string resourceGroupName, string factoryName);

https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.datafactory.pipelinesoperationsextensions.listbyfactory?view=azure-dotnet

Similarly if you are looking for one particular pipeline , you can call below API:

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}?api-version=2018-06-01

same set of operation you can do it using SDK too by using below method:

public static Microsoft.Azure.Management.DataFactory.Models.PipelineResource Get (this Microsoft.Azure.Management.DataFactory.IPipelinesOperations operations, string resourceGroupName, string factoryName, string pipelineName, string ifNoneMatch = null);

https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.datafactory.pipelinesoperationsextensions.get?view=azure-dotnet#Microsoft_Azure_Management_DataFactory_PipelinesOperationsExtensions_Get_Microsoft_Azure_Management_DataFactory_IPipelinesOperations_System_String_System_String_System_String_System_String_

As you can see all the SDK method returns below c# model object which you can serialize in JSON format using NewtonsoftJson library.

Hope it answer your question. Let me know if you any assistance .

Upvotes: 2

Related Questions