Last active
May 17, 2022 19:02
-
-
Save mozziemozz/a908360198d56dd82798164f9e2c4ce0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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