cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ajhstn
Helper I
Helper I

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
v-yamao-msft
Community Support
Community Support

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,177)