https://pulumi.com logo
#azure
Title
# azure
m

mysterious-australia-14256

10/09/2020, 10:48 AM
Hi All, I'm having trouble specifying the definition for a Logic App Workflow in C# as per Resource Workflow | Module logic | Package Azure NextGen | Pulumi. The Definition wants something of Pulumi.Input<object> but I haven't worked out the correct format. I have tried passing in a System.Text.Json.JsonElement created by Deserializing
{"$schema":"<https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#>","actions":{},"parameters":{},"triggers":{},"contentVersion":"1.0.0.0","outputs":{}}
Without luck (I get an error saying that the property $schema wasn't found in the JSON (though I can access it via GetProperty("$schema")). Does anyone know the correct format? I've tried the example code from the above link but that won't build
t

tall-librarian-49374

10/09/2020, 11:51 AM
Yeah, it looks like the Azure API spec isn’t great there, so we generate an untyped object. Do you have a sample for me to try?
Feel free to add your code based on JsonElement and I will try it too
m

mysterious-australia-14256

10/09/2020, 3:59 PM
Thanks @tall-librarian-49374, That's a bit more direct than what I was trying 🙂 I was starting with the following class
Copy code
internal class AzureWorkflowModel
{
    [System.Text.Json.Serialization.JsonPropertyName("$schema")]
    public string schema { get; set; } = "<https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#>";
    public object actions { get; set; } = new object();
    public object parameters { get; set; } = new object();
    public object triggers { get; set; } = new object();
    public string contentVersion { get; set; } = "1.0.0.0";
    public object outputs { get; set; } = new object();
}
and then doing a bit of ugly conversion to get it to a JsonElement
Copy code
var laDefinition = JsonSerializer.Serialize(new AzureWorkflowModel());
var laDefinitionJsonElement = JsonSerializer.Deserialize<System.Text.Json.JsonElement>(laDefinition);
the above then allows me to correctly access the $schema property
Copy code
System.Console.WriteLine(laDefinitionJsonElement.GetProperty("$schema").ToString());
But passing it in to the following code results in the error reported above
Copy code
return new Pulumi.AzureNextGen.Logic.Latest.Workflow(myName, new Pulumi.AzureNextGen.Logic.Latest.WorkflowArgs
{
    WorkflowName = myName,
    Location = myLocation,
    ResourceGroupName = myResourceGroupName,
    laDefinition = laDefinitionJsonElement
});
3 Views