Following steps are taken to create Azure Function in Visual Studio
Azure Function
templateIoT Hub Trigger
Code generated but with reference errors.
using IoTHubTrigger = Microsoft.Azure.WebJobs.EventHubTriggerAttribute;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.EventHubs;
using System.Text;
using System.Net.Http;
using Microsoft.Extensions.Logging;
namespace DeviceMessageFunction_v2
{
public static class Function1
{
private static HttpClient client = new HttpClient();
[FunctionName("Function1")]
public static void Run([IoTHubTrigger("messages/events", Connection = "")]EventData message, ILogger log)
{
log.LogInformation($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.Body.Array)}");
}
}
}
CS0234 The type or namespace name 'EventHubTriggerAttribute' does not exist in the namespace 'Microsoft.Azure.WebJobs' (are you missing an assembly reference?) DeviceMessageFunction_v2 C:\Functions\DeviceMessageFunction_v2\Function1.cs
Tried add references, but no luck
Here is my tools and framework details
When using a V2 function you need to use an extra NuGet Package, Microsoft.Azure.WebJobs.Extensions.EventHubs
(Source)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With