Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion articles/azure-functions/functions-bindings-event-grid-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,53 @@ module.exports = function(context) {

# [Python](#tab/python)

The Event Grid output binding is not available for Python.
The following example shows a trigger binding in a *function.json* file and a [Python function](functions-reference-python.md) that uses the binding. It then sends in an event to the custom Event Grid topic, as specified by the `topicEndpointUri`.

Here's the binding data in the *function.json* file:

```json
{
"scriptFile": "__init__.py",
"bindings": [
{
"type": "eventGridTrigger",
"name": "eventGridEvent",
"direction": "in"
},
{
"type": "eventGrid",
"name": "outputEvent",
"topicEndpointUri": "MyEventGridTopicUriSetting",
"topicKeySetting": "MyEventGridTopicKeySetting",
"direction": "out"
}
],
"disabled": false
}
```

Here's the Python sample to send a event to a custom Event Grid topic by setting the `EventGridOutputEvent`:

```python
import logging
import azure.functions as func
import datetime


def main(eventGridEvent: func.EventGridEvent,
outputEvent: func.Out[func.EventGridOutputEvent]) -> None:

logging.log("eventGridEvent: ", eventGridEvent)

outputEvent.set(
func.EventGridOutputEvent(
id="test-id",
data={"tag1": "value1", "tag2": "value2"},
subject="test-subject",
event_type="test-event-1",
event_time=datetime.datetime.utcnow(),
data_version="1.0"))
```

# [Java](#tab/java)

Expand Down