Open PetkoGotsov opened 3 years ago
@PetkoGotsov: I'm not 100% sure but I think your function (not function app, but the actual function that will subscribe to the topic) has to be EventGrid Trigger type, maybe?
I am having similar issue with different error
Error: waiting for creation/update of System Topic Event Subscription: (Event Subscription Name " " / System Topic Name " " / Resource Group " "): Code="Endpoint validation" Message="Destination endpoint not found. Resource details: resourceId: /subscriptions/ /resourceGroups/ /providers/Microsoft.Web/sites/ /functions/ . Resource should pre-exist before attempting this operation. Activity id:, timestamp: 3/21/2023 1:13:23 PM (UTC)."
Although the function under the function app is running fine:
Also have this issue, and we suspect that Terraform sends the async request to Azure, returns with a 202 without waiting for Azure to return and fully stand up with the Function code, and assumes that the Function endpoint is ready but in reality it's still initializing when Terraform gets to the event_grid resource. It would make sense if there was a data resource for Function_App_Function so that the eventgrid resource would also assume that the function will be there.
A two stage deployment as described here is one solution to this issue.
Community Note
Terraform (and AzureRM Provider) Version
TF.ver: 0.0.142 provider.ver: 2.21.0
Affected Resource(s)
azurerm_eventgrid_event_subscription_resource
Terraform Configuration Files
Expected Behaviour
A event subscription should be created for the function app with an AzureFunction endpoint type to the domain grid topic.
Actual Behaviour
Terraform errors with the following:
*Error: Error waiting for EventGrid Event Subscription "systemmanager-subscription" (Scope "/subscriptions//resourceGroups/systemmanager-dev/providers/Microsoft.EventGrid/topics/systemmanager-topic") to become available: Code="Internal error" Message="The operation failed due to an internal server error. The initial state of the impacted resources (if any) are restored. Please try again in few minutes. If error still persists, report 42b51f3d-c8b9-4fbf-9307-eb384032f065:2/12/2021 2:48:24 PM (UTC) to our forums for assistance or raise a support ticket ."**
I can confirm that the event source resource id is the one that is present in the */subscriptions//resourceGroups/systemmanager-dev/providers/Microsoft.Web/sites/systemmanager-dev-sub-function/functions/EventSubscriptionAzureFunction** properties and that by the time terraform attempts to create the event subscription, the aforementioned azure function is already deployed and running (accepts default validation request and returns validationResponse).