Annotation Type EventGridOutput


  • @Retention(RUNTIME)
    @Target({PARAMETER,METHOD})
    public @interface EventGridOutput

    Place this on a parameter whose value would come from EventGrid, and causing the method to run when an event is arrived. The parameter type can be one of the following:

    • Any native Java types such as String, byte[]
    • Nullable values using Optional<T>
    • Any POJO type

    The following example shows a Java function that prints out an event and then sends an event to a custom eventGrid topic:

    @FunctionName("eventGridMonitor")
     public void logEvent(
        @EventGridTrigger(name = "event") String content,
        @EventGridOutput(name = "outputEvent", topicEndpointUri = "MyEventGridTopicUriSetting",
                                    topicKeySetting = "MyEventGridTopicKeySetting")
                                          OutputBinding<String> outputEvent
         final ExecutionContext context
     ) {
         context.getLogger().info(content);
         final String eventGridOutputDocument = "{\"id\": \"100\", \"eventType\":\"recordInserted\",
             \"subject\": \"myapp/test/java\", \"eventTime\":\"2017-08-10T21:03:07+00:00\",
             \"data\": {\"tag1\": \"value1\",\"tag2\":\"value2\"}, \"dataVersion\": \"1.0\"}";
         outputEvent.setValue(eventGridOutputDocument);
     }
    Since:
    1.4.0
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String name
      The variable name used in function.json.
      java.lang.String topicEndpointUri
      Gets or sets the topic events endpoint URI.
      java.lang.String topicKeySetting
      Gets or sets the Topic Key setting.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String dataType
      Defines how Functions runtime should treat the parameter value.
    • Element Detail

      • name

        java.lang.String name
        The variable name used in function.json.
        Returns:
        The variable name used in function.json.
      • topicKeySetting

        java.lang.String topicKeySetting
        Gets or sets the Topic Key setting. You can find information on getting the Key for a topic here: https://docs.microsoft.com/en-us/azure/event-grid/custom-event-quickstart#send-an-event-to-your-topic
        Returns:
        The topic key setting of the eventGrid topic.
      • topicEndpointUri

        java.lang.String topicEndpointUri
        Gets or sets the topic events endpoint URI. Eg: https://topic1.westus2-1.eventgrid.azure.net/api/events This is found in the Event Grid Topic's definition. You can find information on getting the Url for a topic here: https://docs.microsoft.com/en-us/azure/event-grid/custom-event-quickstart#send-an-event-to-your-topic
        Returns:
        The topic events endpoint URI of the eventGrid topic.
      • dataType

        java.lang.String dataType

        Defines how Functions runtime should treat the parameter value. Possible values are:

        • "" or string: treat it as a string whose value is serialized from the parameter
        • binary: treat it as a binary data whose value comes from for example OutputBinding<byte[]>
        Returns:
        The dataType which will be used by the Functions runtime.
        Default:
        ""