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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (3,756)