I use powershell to loop through multiple Json files obtained by the REST API. But the difficulty is that there are nodes with \
in them, and the name of a node is not fixed, we have no way to get it, wildcards seem to have no effect.
My test Json file Workflow_Info
like:
{
"id": "/subscriptions/fcxxxx7/resourceGroups/xxxxxx/providers/Microsoft.Web/sites/xxxx/workflows/Test_email",
"name": "xxxxxxxxx/Test_email",
"type": "Microsoft.Web/sites/workflows",
"kind": "Stateful",
"location": "East Asia",
"properties": {
"files": {
"Test_email/workflow.json": {
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Send_an_email_from_a_shared_mailbox_(V2)": {
"inputs": {
"host": {
"connection": {
"referenceName": "TheValueIwant"
}
},
"method": "post",
"path": "/v2/SharedMailbox/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {}
},
"kind": "Stateful"
}
}
}
}
What I want to get is the value of the node referenceName.
But there are two difficulties:
The node
Test_email\workflow.json
includes the\
in it, how to parse it?The node
Send_an_email_from_a_shared_mailbox_(V2)
it is not a fixed value, it has different value in different json, I tried to use wildcard*
, but not work.
My test powershell scripts is:
$WorkflowJson = $Workflow_Info | ConvertTo-Json -depth 100
$WorkflowJsonNew = $Workflow_Info.properties.files."$($WorkflowName)/workflow.json".definition.'*'.host.connection.referenceName | ConvertTo-Json -depth 100
Write-Host "The workflow is:$WorkflowJsonNew"