0

I have written an IoT Hub Trigger which gets triggered when data is received and write it to Datalake Storage using output binding.

Current Output Binding :

@BlobOutput(
        name = "target", 
        path = "event/iot-hub-1//BlobTrigger{rand-guid}.json") 

But I want to specify the path to which the output should be written dynamically , something like this:

@BlobOutput(
        name = "target", 
        path = "event/iot-hub-1/{deviceId}/BlobTrigger{rand-guid}.json")

This is the code I have written which doesn't seem to achieve it.

Full Code:

   @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));
      }

Can anyone let me know where am I going wrong or a way by which i can write it dynamically.

0 Answers0