Skip to content

Instantly share code, notes, and snippets.

@mozziemozz
Last active May 17, 2022 19:02
Show Gist options
  • Save mozziemozz/a908360198d56dd82798164f9e2c4ce0 to your computer and use it in GitHub Desktop.
Save mozziemozz/a908360198d56dd82798164f9e2c4ce0 to your computer and use it in GitHub Desktop.
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$action = $Request.Body.action
$uri = ""
$body = @'
{
"@context": "https://schema.org/extensions",
"@type": "MessageCard",
"themeColor": "00A4EF",
"title": "Config Change Request Received",
"text": "Your change has been submitted to the Azure Runbook. The Auto Attendant will be actionPlaceholder."
}
'@
if ($action -eq "open") {
$actionFriendly = "opened"
}
else {
$actionFriendly = "closed"
}
$body = $body.Replace("actionPlaceholder","$actionFriendly")
$runBookBody = @"
{
"action": "$action"
}
"@
Invoke-RestMethod -uri $uri -Method Post -ContentType "application/json" -Body $runBookBody
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
headers = @{'content-type'='application/json'; 'charset'='utf8'; 'CARD-UPDATE-IN-BODY'='true'}
StatusCode = [HttpStatusCode]::OK
Body = $body
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment