Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Webhook to azure functions timeouts

(0) ShareShare
ReportReport
Posted on by 145

Hi,

I have an Azure function and also a registered webhook in plugin registration tool. I've registered a step on an entity update, whenever I update this entity I get this error: 

  • The webhook call failed because the Http request timed out at client side. Please check your webhook request handler.

I've checked the logs of my azure function, no errors. But I noticed that when the execution time is more that 1 min this exception occurs. So is there a timeout for webhook call ? and how to fix this ?

Thanks

  • eric.westpac Profile Picture
    15 on at
    RE: Webhook to azure functions timeouts

    Hi Khaled Rimawi , did you managed to resolved this? I'm having the same issue and my webhook is async. Thanks

  • Khaled Rimawi Profile Picture
    145 on at
    RE: Webhook to azure functions timeouts

    Hi,

    I tried to register the step to run asynchronously and I can see that azure function run duration is much less now , it's almost 6 seconds instead of 60. Any idea why?

  • Khaled Rimawi Profile Picture
    145 on at
    RE: Webhook to azure functions timeouts

    Hi Adrian,

    the Azure function I'm using is a v1 (.net framework) http trigger function, webhook passes the execution context to it, I can see that the azure function runs successfully , but this exception appears on the CRM interface for the user , here is how I registered the webhook:

    pastedimage1606205591526v1.png

    and then i registered a step & image : 

    pastedimage1606205704771v2.png

    pastedimage1606206173148v3.png

    this is a snippet of my code:

     [FunctionName("ResolveProgramScoreLevel")]
            public static async Task Run([HttpTrigger(AuthorizationLevel.Admin,  "post", Route = null)]HttpRequestMessage req, TraceWriter log)
            {
                try
                {
                    if(req == null)
                    {
                        log.Error($"{nameof(req)} is null");
                        return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent($"{nameof(req)} is null") };
                    }
    
                    // Parse request data to json string and retreive relevant data from context
                    string requestJsonContext = req.Content.ReadAsStringAsync().Result;
                    log.Info(requestJsonContext);
                    if (string.IsNullOrEmpty(requestJsonContext))
                    {
                        log.Error($"[{nameof(Run)}] - Invalid request, the recieved context data from the webhook call is null or empty...");
                        return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Invalid request, the recieved context data from the webhook call is null or empty...") };
                    }
    
                    //Retrieve webhook context from request to get relevant incident data 
                    RemoteExecutionContext context = DeserializeJsonString(requestJsonContext);// parse request json data to RemoteExecutionContext object 
    
                    #region context validation
                    //context validation
    
                    //check if this function was requested on an update event
                    if (context.MessageName.ToLower() != "update")
                    {
                        log.Error($"[{nameof(Run)}] - Invalid request, this function was not triggered on update message");
                        return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Invalid request, this function was not triggered on update event") };
                    }
    
                    //check if context contains the target case
                    if (!context.InputParameters.Contains("Target"))
                    {
                        log.Error($"[{nameof(Run)}] - Invalid request, context doesn't contain the target entity");
                        return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Invalid request, context doesn't contain the target entity") };
                    }
    
                    //check if the context contains the image of case
                    if (!context.PostEntityImages.Contains("image"))
                    {
                        log.Error($"[{nameof(Run)}] - Invalid request, context doesn't contain the image entity");
                        return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Invalid request, context doesn't contain the image entity") };
                    }
    
                    #endregion
    
                    var targetCase = ((Entity)context.InputParameters["Target"]).ToEntity();
                    var casePostImage = context.PostEntityImages["image"].ToEntity();
    
                    var testScore = casePostImage.Contains("new_testscore") ? Convert.ToDouble(casePostImage.Attributes["new_testscore"]) : (double?)null;
                    var requestReason = casePostImage.Contains("new_loa_request_reason") ? (casePostImage.Attributes["new_request_reason"] as EntityReference).Id : (Guid?)null;
    
                    if (targetCase.new_requestsubstatusid != null &&
                       targetCase.new_requestsubstatusid.Id == //some value &&
                       testScore != null &&
                       casePostImage.SubjectId != null &&
                       casePostImage.SubjectId.Id == //some value){
    						// do some logic
    				   }
    				   
    				   return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
    			}
    			catch (Exception ex)
                {
                    log.Error($"[{nameof(Run)}] - an error has occured, ex : {ex}");
                    return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(ex.ToString()) };
                }	
        	}
        	
        	 private static RemoteContextType DeserializeJsonString(string jsonString)
            {
                //create an instance of generic type object
                RemoteContextType obj = Activator.CreateInstance();
                MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(jsonString));
                System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
                obj = (RemoteContextType)serializer.ReadObject(ms);
                ms.Close();
    
                return obj;
            }

    these are the invocations of my function , it runs fine:

    pastedimage1606206326952v4.png

  • Suggested answer
    Adrian Begovich Profile Picture
    1,023 Super User 2025 Season 1 on at
    RE: Webhook to azure functions timeouts

    Hi Khaled Rimawi,

    Are you passing parameters into a Durable Function? This error can occur if the parameters passed into a Durable Function are not read correctly. It would be good to take a look at your webhook and any associated code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,125 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,871 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans