microsoft / IoT-For-Beginners

12 Weeks, 24 Lessons, IoT for All!
https://microsoft.github.io/IoT-For-Beginners/
MIT License
15.28k stars 2.39k forks source link

firewall blocked iot hub event trigger #461

Closed kimanigitau01 closed 1 year ago

kimanigitau01 commented 1 year ago

I have encountered this problem while doing the task on lesson 12 Transport: store location data on Task - handle GPS events using serverless code

Found Python version 3.10.11 (py).

Azure Functions Core Tools
Core Tools Version:       4.0.5148 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.17.3.20392

Functions:

        iot-hub-trigger: eventHubTrigger

For detailed output, run func with --verbose flag.
[2023-05-08T16:47:42.037Z] Worker process started and initialized.
[2023-05-08T16:48:19.260Z] The listener for function 'Functions.iot-hub-trigger' was unable to start.
[2023-05-08T16:48:19.264Z] The listener for function 'Functions.iot-hub-trigger' was unable to start. Azure.Core: Retry failed after 6 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy. (No connection could be made because the target machine actively refused it. (127.0.0.1:10000)) (No connection could be made because the target machine actively refused it. (127.0.0.1:10000)) (No connection could be made because the target machine actively refused it. (127.0.0.1:10000)) (No connection could be made because the target machine actively refused it. (127.0.0.1:10000)) (No connection could be made because the target machine actively refused it. (127.0.0.1:10000)) (No connection could be made because the target machine actively refused it. (127.0.0.1:10000)). Azure.Core: No connection could be made because the target machine actively refused it. (127.0.0.1:10000). System.Net.Http: No connection could be made because the target machine actively refused it. (127.0.0.1:10000). System.Net.Sockets: No connection could be made because the target machine actively refused it.
[2023-05-08T16:48:49.617Z] The listener for function 'Functions.iot-hub-trigger' was unable to start.
[2023-05-08T16:48:49.620Z] The listener for function 'Functions.iot-hub-trigger' was unable to start. System.Private.CoreLib: A task was canceled.
kimanigitau01 commented 1 year ago

Solved

the problem is caused by not starting the azurite app from vs code

Note: The new azure event hub template has some new bugs if you use it 1.

from typing import List
import logging

import azure.functions as func

def main(events: List[func.EventHubEvent]):
     for event in events:
         logging.info('Python EventHub trigger processed an event: %s',
                         event.get_body().decode('utf-8'))

this produces an an event not irritable solution: use the initial template from the task instructions