Search code examples
azurejson-deserializationazure-data-factorycustom-activity

ADFV2 Custom Activity


Building on the example given here in ADFV2 documentation - https://learn.microsoft.com/en-us/azure/data-factory/transform-data-using-dotnet-custom-activity#executing-commands

The code snippet from the same documentation mentioned above, can't be used as is -

dynamic activity = JsonConvert.DeserializeObject(File.ReadAllText("activity.json")); Console.WriteLine(activity.typeProperties.extendedProperties.connectionString.value

As this would give a RuntimeBinderException: 'Newtonsoft.Json.Linq.JValue' does not contain a definition for 'value'


Solution

  • I'm not sure about the connection string format, but I have several custom (Azure Batch) activities running in ADFv2. I use ".ToString()" instead of ".value" in the console app:

        // Parse activity and reference objects info from input files
        var parameters = new Dictionary<string, string>();    
        dynamic activity = JsonConvert.DeserializeObject(File.ReadAllText("activity.json"));
        parameters.Add("url", activity.typeProperties.extendedProperties.Url.ToString());