Echo webhook data in Azure Automation

When working with Azure Automation I quite often work with requests from external systems. In some cases the developers working with the external system wants to see the data at the Azure Automation end. In the event the developer doesn’t have access to Azure Automation itself this can be tricky.

This is why I decided to create a simple app to echo the received data (and errors if any) back to the developer.

param (
    [object]$WebhookData 
)

#Variables
$Sender = "echo@technut.se"
$Recipient = "developer@externalcompany.com"
$SMTPServer = "smtprelay.technut.se"

$Out = @()

$RAW = $WebhookData.RequestBody
$Converted = ConvertFrom-Json -InputObject $WebhookData.RequestBody

$Out += "Body (RAW): $RAW"
$Out += "Body (ConvertFrom-JSON): $Converted"
$Out += "Error: $Error"

#Echo via e-mail
$Body = $Out -join "`r`n" | Out-String
Send-MailMessage -SmtpServer $SMTPServer -To $Recipient -From $Sender -Subject "Webhook Echo" -Body $Body

#Echo in log
$Out

This allows the developers to test sending data to Azure Automation without me confirming data was received and correct.

Leave a Reply

Your email address will not be published. Required fields are marked *