Hassan Shabbir
Hassan Shabbir

Reputation: 23

IotHubTrigger Is not working in Azure Function

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.

Upvotes: 0

Views: 135

Answers (1)

Sampath
Sampath

Reputation: 3639

  • 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.

Upvotes: 0

Related Questions