0

I have a Shelly Motion Sensor 2 that is set up to trigger an anonymous Azure Function using .NET 6 isolated process runtime. But the Azure Function HTTP trigger is not being triggered properly.

The device is not able to use HTTPS, so I am allowing HTTP. Developing locally the device triggers the Azure Function properly every time when calling GET http://192.168.1.83/api/ping. When using GET http://x-y-z.azurewebsites.net/api/ping the function doesn't get triggered most of the time, but it strangely enough does work other times. Using Postman or curl it works every time.

    [Function("Ping")]
    public async Task<HttpResponseData> Ping(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "ping")] HttpRequestData request)
    {
        var response = request.CreateResponse(HttpStatusCode.OK);
        await response.WriteStringAsync("pong");

        return response;
    }

The Shelly device can trigger multiple HTTP GET requests at the same time and I've set the device up to trigger a Google Cloud Function, a http://webhook.site endpoint and a http://requestinspector.com endpoint. These also work every time.

Here are the logs from the device:

    1674085196.780 action_queue_process:    URL[http://a.cloudfunctions.net/ping] Connecting
    1674085196.856 action_queue_process:    URL[http://webhook.site/a-b-c-d] Connecting
    1674085196.989 action_queue_process:    URL[http://x-y-z.azurewebsites.net/api/ping] Connecting
    1674085196.013 action_queue_process:    URL[http://a.cloudfunctions.net/ping]: Done
    1674085196.027 action_queue_process:    URL[http://webhook.site/a-b-c-d]: Done
    1674085196.098 action_queue_process:    URL[http://x-y-z.azurewebsites.net/api/ping]: Done

The request looks like this according to requestinspector.com:

    GET /inspect/abcxyz HTTP/1.1
    requestinspector.com
    Accept: */*
    User-Agent: Mozilla/5.0
    Accept-Encoding: gzip

I've tried mimicking the headers with curl, but it does not affect anything, the function is still triggered. I've checked Application Insights and logs, but most of the time I don't see anything since the request is not even registered.

I also tried having the device calling an Azure App Service HTTP endpoint and it did not register in Application Insights either.

Is there some sort of built-in protection in Azure preventing the requests from going through? Or am I missing something else? I'm using a B1 app service plan.

Martin H
  • 349
  • 4
  • 16
  • 1
    Are you being rate limited somewhere? And, check your logging level. You might have to increase the level to see these types of errors. – iohans Jan 19 '23 at 03:32
  • How do you validate that not all requests are coming through? – Peter Bons Jan 19 '23 at 07:58
  • Monitoring with Wireshark I can see that there are no response from Azure. According to Microsoft support the requests trigger a 400 Bad Request, but it's nothing I can see in my logging or Application Insights. Google Cloud Functions work. Azure App Service does not work. It seems like there is some happening on a lower level. – Martin H Jan 19 '23 at 12:09

0 Answers0