Azure Functions - Azure Iot 中心不触发功能
Azure Functions - Azure Iot hub not triggering Functions
我的函数永远不会触发。
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)}");
}
}
}
为了向 IotHub 发送消息,我使用 this script
先谢谢那些能赐教的人了!
尝试使用 EventHubTrigger
属性而不是 IoTHubTrigger
属性并按照示例 here.
好吧,肯定是一个糟糕的操作。我在 C#(和打字稿)中删除并重新开始,它有效!
更新:我刚刚忘记将 AzureEventHubConnectionString 变量放入我的 Azure 函数的配置中!
我的函数永远不会触发。
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)}");
}
}
}
为了向 IotHub 发送消息,我使用 this script
先谢谢那些能赐教的人了!
尝试使用 EventHubTrigger
属性而不是 IoTHubTrigger
属性并按照示例 here.
好吧,肯定是一个糟糕的操作。我在 C#(和打字稿)中删除并重新开始,它有效! 更新:我刚刚忘记将 AzureEventHubConnectionString 变量放入我的 Azure 函数的配置中!