Thanks for posting your question in Microsoft Q&A.
#1 The code snippet is incorrect which uses route
instead of event_grid_trigger
and missing few references. I see a solution with modified code snippet is provided in this discussion (let me know if any issues) and doc issue: https://github.com/MicrosoftDocs/azure-docs/issues/120627 was opened to address this. I already submitted PR for review and the changes will be merged soon. Sorry for the inconvenience caused by this issue.
#2 Event Grid extension for Azure Functions supports CloudEvents v1.0 schema (for C#). However, SDK for Python still doesn't have a model for CloudEvents and only EventGridOutputEvent (don't think it support CloudEvents). There is an open item: CloudEvents schema in Python functions for this and I am reaching out to our product team and will update it. Please track this item for the latest.
I hope this helps and let me know if any questions.
If you found the answer to your question helpful, please take a moment to mark it as Yes
for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.