问题描述
我编写了一个 IoT 中心触发器,它会在接收到数据时触发,并使用输出绑定将其写入 Datalake Storage。
电流输出绑定:
@BlobOutput(
name = "target",path = "event/iot-hub-1//BlobTrigger{rand-guid}.json")
但我想指定应该动态写入输出的路径,如下所示:
@BlobOutput(
name = "target",path = "event/iot-hub-1/{deviceId}/BlobTrigger{rand-guid}.json")
这是我写的似乎没有实现它的代码。
完整代码:
@FunctionName("OutputBind_trigger")
public void run(
@BindingName("SystemProperties") Map<String,Object> systemProperties,@EventHubTrigger(name = "message",eventHubName = "iot-hub-1",connection = "ConnectionString",consumerGroup = "$Default",cardinality = Cardinality.ONE) String message,@BlobOutput(
name = "target",path = "event/iot-hub-1/{deviceId}/BlobTrigger{rand-guid}.json")
OutputBinding<String> outputItem,final ExecutionContext context )
{
context.getLogger().info("Java Event Hub trigger function executed.");
context.getLogger().info("Event hub message received: " + message);
deviceId = (String) systemProperties.get("iothub-connection-device-id");
data =message.getBytes();
System.out.println("Device Id is : "+deviceId);
outputItem.setValue(new String(message.getBytes(),StandardCharsets.UTF_8));
}
谁能告诉我我哪里出错了或者我可以动态编写它的方式。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)