Home > Net >  Accessing post query params in Azure webhook
Accessing post query params in Azure webhook

Time:03-09

I am trying to read the URL query params from a POST coming into my Azure webhook (PowerShell).

My webhook is receiving a POST request such as:

Content-Type: text/plain; charset=utf-8
POST https://{notificationUrl}?validationToken={opaqueTokenCreatedByMicrosoftGraph}

As you may tease out, the context here is the creation of a Azure Runbooks

The Runbook (Right Box) only accepts the single WebhookData object to manage variable and data that Azure Runbooks will operate with.

Webhooks (Left Box), handles the triggering, receiving of data and passing it on to the Runbook. Very specifically, the RequestBody is specified as the:

Body of the incoming POST request. This body keeps any data formatting, such as string, JSON, XML, or form-encoded.This body keeps any data formatting, such as string, JSON, XML, or form-encoded.

With this definition, very specifically, even though WebHooks can support query strings, in this case for triggering Azure Runbooks they are explicitly ignored.


Aside, if the end desire is to subscribe to Microsoft Graph events, the "better" way is to use Event Hubs to handle notifications:

Using Azure Event Hubs to receive change notifications differs from webhooks in a few ways, including:

  • You don't rely on publicly exposed notification URLs. The Event Hubs SDK will relay the notifications to your application.
  • You don't need to reply to the notification URL validation. You can ignore the validation message that you receive.
  • You'll need to provision an Azure Event Hub.
  • You'll need to provision an Azure Key Vault.
  • Related