In a workflow, it should be a common requirement to pass the output of one step to another step. The motivation to post this working solution, is there is no clear example that illustrates how exactly that is done. It should be learned in a few minutes, rather than hours of trial and error.
output from step 1
Using a simple two step workflow to illustrate, in step 1, we use an Azure Function App with a powershell script. We can obtain a user email dynamically from Azure VM's user defined tag field.
$user_email = (Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name $resourceName
-ErrorAction $ErrorActionPreference -WarningAction $WarningPreference).Tags["user_email"]
More importantly, the obtained result needs to be sent to this rather odd "Out-File" structure. This is how variable can be passed in the workflow:
$result = $user_email | ConvertTo-Json
Out-File -Encoding Ascii -FilePath $res -inputObject $result
Out-File -Encoding Ascii -FilePath $res -inputObject $result
input to step 2
In a subsequent step, we can use the output of previous step, in this case, sending an email to VM's user per tag. This is best illustrated using the graphical interface of Logic App Designer:Azure recognized a step generates an output, and make it available to be used for subsequent steps. The particular handle is shown as "Body" of Step 1 Function App, again, rather odd representation.
But it does work. And this simple mechanism is a much needed building block to construct complex features in a workflow.
No comments:
Post a Comment