Runbook output JSON schema assistance

Jurgen Verhelst 326 Reputation points
2020-12-29T06:33:15.517+00:00

Hi,

Trying to get the output of a runbook sent to a sharepoint list 'runbook log' as an attachement in a list item

testing now just getting it mailed to me, but I get jiberish formatting

I tried some JSON schema generators but kind of in the dark what I am actually doing :)

the runbook does something simple for now

Get-AzureADSubscribedSku | Select -Property Sku*,ConsumedUnits -ExpandProperty PrepaidUnits   

In powershell it looks like this:
51805-screenshot-2020-12-29-073121.png

this is what I get via email
51875-screenshot-2020-12-29-071743.png
Saw a post I had to Parse it to JSON, ok... so added that step, but it asks for a JSON schema. how can I create a schema if I do not know what I am getting. Ah the step suggests creating a schema for me. how nice :) . but whatever data I add in that box, its never satisfied ;)

I tried a couple of JSON schema generators but actually have no clue how to begin here

this is how a run looks like with my attempt of adding a JSON schema

51888-screenshot-2020-12-29-071639.png

any direction you guys can point me?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,938 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,160 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 69,851 Reputation points
    2020-12-29T14:06:36.583+00:00

    Hi @Jurgen Verhelst

    I can see that the input content is not in the JSON format therefore you are getting the exception.
    Please refer to Parse JSON action for more details on when and how the parse json action is used. If you look into the document you will see that in the example they are first Initializing the variable of JSON object then they are using parse json action on the initialize json object.

    I believe that you are passing "Get job output" action output value to the input for "Parse JSON" action. Then in that case your action should return the JSON object rather than data as below format :

    51940-image.png

    If I run your command and convert the output to JSON :
    (Get-AzureADSubscribedSku | Select -Property Sku*,ConsumedUnits -ExpandProperty PrepaidUnits) | ConvertTo-Json

    I see the below output which is different from what I see in the input of your Parse JSON action so there would be other steps to get your desired output.

    [  
      {  
        "Enabled": 1,  
        "Suspended": 0,  
        "Warning": 0,  
        "SkuId": "d4cc2f49-c31e-4613-b8fc-a4c5d46da8e2",  
        "SkuPartNumber": "Dynamics_365_for_Operations_Sandbox_Tier1_SKU",  
        "ConsumedUnits": 0  
      },  
      {  
        "Enabled": 800000,  
        "Suspended": 0,  
        "Warning": 0,  
        "SkuId": "c5928f49-12ba-48f7-ada3-0d743a3601d5",  
        "SkuPartNumber": "VISIOCLIENT",  
        "ConsumedUnits": 290391  
      }]  
    

    Assuming that after making changes to your job and formatting the output to json by using | ConvertTo-Json you will see below output

    [{  
        "Account": "Test",  
        "Environment": "TestCloud",  
        "Tenant": "3d957427-ecdc-4df2-aacd-01cc9d519da8",  
        "TenantId": "3d957427-ecdc-4df2-aacd-01cc9d519da8",  
        "TenantDomain": "TestDomain"  
    }]  
    

    Using your output json you can generate the schema by clicking on "Use Sample payload to generate schema"
    52081-image.png

    Payload generated with the above json data:

    {  
        "properties": {  
            "Account": {  
                "type": "string"  
            },  
            "Environment": {  
                "type": "string"  
            },  
            "Tenant": {  
                "type": "string"  
            },  
            "TenantDomain": {  
                "type": "string"  
            },  
            "TenantId": {  
                "type": "string"  
            }  
        },  
        "type": "object"  
    }  
    

    Now you can use the dynamic content list in your next action according to your needs. You need to pass the JSON data to Parse JSON action to make it work correctly.

    Feel free to get back to me if you need any help.


0 additional answers

Sort by: Most helpful