I'm literally using microsoft azure official documentation for event grid output binding. and this is there code. I'm using python V2 which doesn't rely on function.json, however i keep getting errors on function.json, why?
import logging
import azure.functions as func
import datetime
app = func.FunctionApp()
@app.function_name(name="eventgrid_output")
@app.route(route="eventgrid_output")
@app.event_grid_output(
arg_name="outputEvent",
topic_endpoint_uri="MyEventGridTopicUriSetting",
topic_key_setting="MyEventGridTopicKeySetting")
def eventgrid_output(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"))
This is the exception i keep getting!
Exception: FunctionLoadError: cannot load the test function: the following parameters are declared in Python but not in function.json: {'eventGridEvent'}
Easily runing since it;s on their official page
Initially I am also getting same errors by followed the DOC eventgrid output binding.
function code:
The above code executed successfully. check below:
Output: