Last active
August 3, 2018 15:22
-
-
Save ehrnst/3fecfa65fad3e55a914dadd4282b6cd3 to your computer and use it in GitHub Desktop.
azure function return event grid validation event
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
# POST method: $req | |
$requestBody = Get-Content $req -Raw | ConvertFrom-Json | |
## validate event grid as described in https://docs.microsoft.com/en-us/azure/event-grid/security-authentication | |
# check event type and return a Json object with the correct validation response | |
if ($requestBody.eventType -eq "Microsoft.EventGrid.SubscriptionValidationEvent") { | |
$code = $requestBody.data.validationCode | |
$content = @{ validationResponse = $code } | |
$message = convertto-json -compress -InputObject ([ordered]@{ | |
body = $content | |
statusCode = 200 | |
}) | |
Out-File -Encoding Ascii -FilePath $res -inputObject $($message) | |
write-output $message | |
} | |
## continue main script | |
# Get event grid data | |
$data = $requestBody.data | |
$name = $data.name | |
Out-File -Encoding Ascii -FilePath $res -inputObject "hello $name" | |
write-output "hello $name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment