0

I am using .Net SDK for creating the pipelines and its Datasets, Linked services. I am having a doubt that we can get values from JSON templates and pass those values to the built-in methods. The following Class is used to create Azure Storage Linked Service.

    client.LinkedServices.CreateOrUpdate(resourceGroupName, dataFactoryName,
                new LinkedServiceCreateOrUpdateParameters()
                {
                    LinkedService = new LinkedService()
                    {
                        Name = "AzureStorageLinkedService",
                        Properties = new LinkedServiceProperties
                        (
                            new AzureStorageLinkedService("DefaultEndpointsProtocol=https;AccountName=**StorageName**;AccountKey=**StorageKey**")
                        )
                    }
                }
            );

I have to get the values for Name and Properties from the JSON Template and pass those values to LinkedServiceCreateOrUpdateParameters Class.

Arron
  • 1,134
  • 2
  • 13
  • 32

1 Answers1

1

As far as I know, you could use LinkedServiceCreateOrUpdateWithRawJsonContentParameters instead of the LinkedServiceCreateOrUpdateParameters .

LinkedServiceCreateOrUpdateWithRawJsonContentParameters has content property which could set the json template parameters.

More details, you could refer to this example.

Json file:

{
    "name": "AzureStorageLinkedService",
    "properties": {
        "type": "AzureStorage",
        "description": "",
        "typeProperties": {
            "connectionString": " "      }
    }
}

Net code:

LinkedServiceCreateOrUpdateWithRawJsonContentParameters d1 =  new LinkedServiceCreateOrUpdateWithRawJsonContentParameters();

string path = @"D:\json2.txt";

using (StreamReader s1 = new StreamReader(path))
{

    d1.Content = s1.ReadToEnd();
}


Console.WriteLine("Creating Azure Storage linked service");

client.LinkedServices.BeginCreateOrUpdateWithRawJsonContent(resourceGroupName, dataFactoryName,"linkservicename", d1);

Result:

enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65