简体   繁体   English

Azure 功能 - Azure 物联网集线器未触发功能

[英]Azure Functions - Azure Iot hub not triggering Functions

My function is never trigger.我的 function 永远不会触发。

local.settings.json local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=storageaccounttesti9ad4;AccountKey=XXX;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureEventHubConnectionString": "Endpoint=sb://iothub-ns-iothub-tes-10126268-5c2cc2a05d.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=YYY;EntityPath=iothub-test-001"
  }
}
namespace functionapp2
{
    public static class Function1
    {
        private static HttpClient client = new HttpClient();
        //iothub-test-001
        [FunctionName("Function1")]
        public static void Run([IoTHubTrigger("iothub-test-001", Connection = "AzureEventHubConnectionString")]EventData message, ILogger log)
        {
            log.LogInformation($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.Body.Array)}");
        }
    }
}

For sending message to IotHub I use this script为了向 IotHub 发送消息,我使用这个脚本

Thanks in advance to those who can enlighten me!提前感谢那些可以启发我的人!

Try using the EventHubTrigger attribute instead of IoTHubTrigger attribute and follow the example here .尝试使用EventHubTrigger属性而不是IoTHubTrigger属性并按照此处的示例进行操作。

Ok, surely a bad manipulation.好吧,肯定是一个糟糕的操纵。 I deleted and started again in C# (and typescript) and it works: Update : I have just forgotten to put AzureEventHubConnectionString variable in the configuration of my Azure Function !我在 C#(和打字稿)中删除并重新开始,它可以工作:更新:我刚刚忘记将 AzureEventHubConnectionString 变量放入我的 Azure Z86408593C34AF77FDD1Z90DF932F8B52 的配置中!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM