cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ajhstn
Level: Powered On

Help passing data from azure automation to flow

Hey, i have a powerapp that takes a text input field and passes it through to a flow.  The flow takes the text input string from the powerapp and creates an azure automation powershell job.  The flow waits while the automation job executes, then receives the runbook output.  This is where i am stuck.  The format of the runbook output is not json, so i can't use a parse json action and i don't know any other way of parsing the output to use further down the flow.

 

The runbook itself, is a simple powershell script that performs a get-azureaduser -objectid $upn.  The $upn is a runbook parameter, and provided by the user in the powerapp.  

 

This is the output of the content field from the "Get job output" flow action.  Its format is a combination of PSObject (maybe) and JSON..

 

Account      : automation@domain.com
Environment  : AzureCloud
Tenant       : nnnn-nnnn-nnnn-nnnn-nnnn
TenantId     : nnnn-nnnn-nnnn-nnnn-nnnn
TenantDomain : domain.onmicrosoft.com

{
    "UPN":  "user1@domain.com",
    "Department":  "Technology",
    "Title":  "Information Technology",
    "Country":  "Australia",
    "ImmutableId":  "nnnnnn"
}

 

 Screen Shot 2019-07-10 at 21.37.19.png

 

Here is the runbook powershell code.

 

Param
(
  [Parameter (Mandatory= $true)]
  [string] $UPN = ""
)
import-module azuread
$creds = Get-AutomationPSCredential -Name 'creds'
connect-azuread -credential $creds
$u = get-azureaduser -objectid $UPN

$objOut = [PSCustomObject]@{
UPN = $u.UserPrincipalName
Department = $u.Department
Title = $u.JobTitle
Country = $u.Country
ImmutableId = $u.ImmutableId

}
Write-Output ( $objOut | ConvertTo-Json)

 

Here is the failure.

 

 

InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value '
 Account      : automation@domain.com
Environment  : AzureCloud
Tenant       : nnnn-nnnn-nnnn-nnnn-nnnn
TenantId     : nnnn-nnnn-nnnn-nnnn-nnnn
TenantDomain : domain.onmicrosoft.com

{
    "UPN":  "user1@domain.com",
    "Department":  "Technology",
    "Title":  "Information Technology",
    "Country":  "Australia",
    "ImmutableId":  "nnnnnn"
}
 ' cannot be parsed: 'Unexpected character encountered while parsing value: A. Path '', line 0, position 0.'.

 

1 REPLY 1
Community Support Team
Community Support Team

Re: Help passing data from azure automation to flow

Hi @ajhstn ,

 

When using the Parse Json action, you need to provide a valid JSON file.

 

You may take the following docs for a reference:

https://flow.microsoft.com/en-us/blog/five-services-json-http/

https://prairiedeveloper.com/2018/12/parsing-json-in-microsoft-flow/

 

Please try with item function to get the needed property:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#i...

 

Best regards,

Mabel          

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 291 members 5,235 guests
Please welcome our newest community members: