Hello Robert Simons,
Thank you for reaching out. It can be frustrating when Azure deployments fail, especially when the portal seems to recognize all the components. The error "the function does not exist" when creating an Event Subscription, despite the function being visible in the dropdowns, usually points to an issue with endpoint validation or a slight delay in the backend services.
Based on similar issues faced by other users, here are the most common causes and how to resolve them.
Endpoint Validation and Cold Starts
A likely cause for this failure is related to the endpoint validation handshake. When you create an Event Grid subscription, Event Grid sends a validation request to the specified endpoint (your Azure Function). The endpoint must respond successfully within a short period for the subscription to be created.
Since you mentioned the function was added recently (~2 hours ago), it might have been in a "cold start" state or not yet fully propagated across all Azure services when you attempted to create the subscription. If the function didn't respond to the validation request in time, Event Grid would fail the deployment, sometimes with a misleading error like "endpoint not found" or "does not exist".
Recommendation: The simplest first step is to wait a little longer and then try creating the event subscription again. Often, this resolves the issue as the function app becomes fully warmed up and responsive.
Troubleshooting Further Issues
If waiting and retrying doesn't work, here are several other common configuration issues to investigate:
Function Bindings and Packages: A frequent solution involves updating the function's configuration. In your C# project, ensure you are using the CloudEvent binding parameter instead of EventGridEvent and have the Microsoft.Azure.WebJobs.Extensions.EventGrid NuGet package installed.
Event Schema Mismatch: Verify that the event schema of your Event Grid Topic matches what the function endpoint is configured to receive. For instance, if the topic uses CloudEventSchemaV1_0, your function and subscription should be aligned. Mismatches can cause the update to fail, with errors indicating that the Azure Function destination only supports EventGridSchema.
Check Function Logs: Inspect the logs for your Azure Function in Application Insights. The logs may contain more specific error messages from when Event Grid attempted to make the validation call, which can help pinpoint the root cause.
Verify Endpoint Accessibility: Ensure the function's endpoint is correct and publicly accessible. If your function has authentication enabled, make sure the Event Grid subscription is configured correctly to handle it, as this could also block the validation request.
In most cases, the problem is temporary due to the initial function deployment and resolves itself. If not, checking the bindings and schema settings is the next logical step.
Best Regards,
Jerald Felix