Reputation: 3
In a customer szenario I'm working on a solution where I want to respond on incoming emails from a M365 group mailbox. I've set up a webhook to subscribe to the group mailbox and trigger an Azure Function.
The Azure Function is written in PowerShell:
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request: $($Request.Query)"
# Interact with query parameters or the body of the request.
$validationToken = $Request.Query.ValidationToken
if ($validationToken) {
Write-Host "Function was called with Validation-Token: $($validationToken). Returning Token"
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $validationToken
})
return
}else{
Write-Host "Validation-Token not found"
}
$notifcations = $Request.Body.value
Write-Host "Got $($notifcations.Count) notifications"
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = "Webhook called successfully"
})
The webhook registration is done via a POST request using Graph Explorer. URL: https://graph.microsoft.com/v1.0/subscriptions Body:
{
"changeType": "created,updated",
"clientState": "Subscription Test",
"expirationDateTime": "2024-04-17T04:26:28.7712196Z",
"notificationUrl": "{function-url}",
"resource": "groups/{group-id}/conversations"
}
In the log console of the Azure Function, I can see that the validation request reaches the Azure Function. However, when I send an email to the group mailbox, the Azure Function is not triggered.
I've already replicated this behavior in another tenant.
When I don't register the webhook on the group conversations but instead, for example, on the group owner, I receive information in the Azure Function when a user is added to the group owners, for instance.
Unfortunately, the Microsoft Support wasn't helpful either.
Can someone replicate the behavior?
Upvotes: 0
Views: 38