Question

Hello,

I have an event receiver set up on a list in SharePoint online. I have a provider-hosted SharePoint Add-In running in Azure, which hosts a remote event receiver service that is called when an event happens on the list.

For the last week or so, there have been several instances when an item was updated on SharePoint Online and my service was not hit by SharePoint Online. I confirmed this by checking my IIS logs on the Add-Ins web server. These events get fired a lot, so I'd say this is about 3-5% of the time (meaning, 95-97% of the time, the events are firing ok).

How can I tell where this is failing, i.e. SharePoint Online (not actually firing the event) vs. Azure (not able to be reached by SharePoint Online)?

I have tried support, but so far they are saying they cannot support this ticket.

Was it helpful?

Solution

Microsoft doesn't guarantee that the Remote Event Receivers will always fire, so it can be difficult to diagnose these kinds of problems to determine if its your code or SharePoint Online.

What you really want is a way to see the SharePoint Online logs to see if there is an error. A previous Stack Exchange question, View uls logs for sharepoint online, addresses this.

See if the logs show any errors, and if they do, look for the 'Correlation ID' for that error, and then try to find other messages in the log that have the same 'Correlation ID'.

In addition to checking your IIS logs, you might also want to add something like this to your Remote Web's Remote event receiver:

public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
        LogInfo(String.Format("After URL: {0}; Before Url {1}; ListID {2}, ListItemID {3}, ListTitle{4}, WebUrl {5}, Event Type: {6}; Current User ID {7}; Current User Login Name {8}; Correlation ID {9}",
                        properties.ItemEventProperties.AfterUrl,
                        properties.ItemEventProperties.BeforeUrl,
                        properties.ItemEventProperties.ListId,
                        properties.ItemEventProperties.ListItemId,
                        properties.ItemEventProperties.ListTitle,
                        properties.ItemEventProperties.WebUrl,
                        (int) properties.EventType,
                        properties.ItemEventProperties.CurrentUserId,
                        properties.ItemEventProperties.UserLoginName,
            properties.CorrelationId);

        ...

    }

    public void LogInfo(String message)
    {
        // Log this message using log4Net, System.Diagnostics, Event Viewer or whatever you prefer 
        // for your "Remote Web" website
    }

This might give you insights into a user permission or other kind of error that is happening with your event receivers. It will also give you a way to confirm or deny that the Event Receiver is not being called for certain files or list items.

Finally, make sure that your Remove Event Receiver always processes and returns very quickly (Threads and TPL can help you out a lot here). I've certainly seen Remote Event Receivers disabled because they were taking too long to process.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top