0

I am getting issue IoTHubtrigger in azure function, Befor eit was working fine but suddenly it stops to triggered in azure function. Here is my azure function Code:

`using IoTHubTrigger = Microsoft.Azure.WebJobs.ServiceBus.EventHubTriggerAttribute;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.ServiceBus.Messaging;
using System.Text;
using System.Net.Http;
namespace TestIot
{  
    public static class Function1
    {
        private static HttpClient client = new HttpClient();

        [FunctionName("Function1")]
        public static void Run([IoTHubTrigger("messages/events", Connection = "IoTHubEndpoint")]EventData message, TraceWriter log)
        {
            log.Info($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.GetBytes())}");
        }
    }
}`

enter image description here

enter image description here

enter image description here

can someone help me with this issue everything i configured in proper way but still not getting message in azure function. If some help me with my issue it would be really appreciated.

I am trying to trigger IoT Hub message in azure function but still not getting any message on azure function ,when i try to send message form simulator device message reached to IOTHUB but not triggering in azure function.

  • for IotHubTrigger in Azure Function Refer this [Link](https://stackoverflow.com/questions/52743156/azure-functions-how-to-set-up-iothubtrigger-for-my-iothub-messages) – Sampath Jul 31 '23 at 06:01
  • refer [this](https://stackoverflow.com/questions/64466625/problems-with-azure-function-app-triggered-by-iot-hub-using-visual-studio-code) – Sampath Jul 31 '23 at 10:12
  • with [event](https://learn.microsoft.com/en-us/answers/questions/1166602/tutorial-for-creating-iot-hub-triggered-azure-func) – Sampath Jul 31 '23 at 10:14

1 Answers1

0
  • Using this Azure Functions how to set up IoTHubTrigger for IoTHub messages.
private static HttpClient client = new HttpClient();
 [FunctionName("Function1")]
  public static void Run([IoTHubTrigger(“messages/events”, Connection = “IoTHubEndpoint”)]EventData message, TraceWriter log)  
{  
log.Info($“C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.GetBytes())}”);  
}

  • Azure IoT Hub trigger for Azure Functions .Rebuild and run the soultion again.

In Azure Portal:

enter image description here

enter image description here

  • For More details refer to this SO.
Sampath
  • 810
  • 2
  • 2
  • 13
  • Hi @Sampath Still not working in local even not getting any message in azure function. I followed properly those links which you mentioned. Using V4 and .net6 – Hassan Shabbir Aug 04 '23 at 15:19
  • Refer [MSDOC](https://learn.microsoft.com/en-us/answers/questions/1166602/tutorial-for-creating-iot-hub-triggered-azure-func) and [SO](https://stackoverflow.com/questions/64466625/problems-with-azure-function-app-triggered-by-iot-hub-using-visual-studio-code) – Sampath Aug 08 '23 at 05:33