Debugging SharePoint Online Provider Hosted App Remote Event Receivers

This post is a contribution from Charls Tom Jacob, an engineer with the SharePoint Developer Support team

Update on 30-Apr-2014: Note: SAS Service Bus connection strings have been supported in Visual Studio 2015 RC and Office Developer Tools for Visual Studio 2013 – April 2015 Update for SharePoint remote event receiver debugging.

If you are finding it difficult to debug your remote event receiver, most probably you would be using an incorrect connection string to connect to the Microsoft Azure Service Bus. Visual Studio Error List will show

“Cannot register Services/RemoteEventReceiver1.svc on Microsoft Azure Service Bus: The remote server returned an error: (500) Internal Server Error.”

Important point to note here is:

Microsoft Azure Service Bus supports two types of connection strings: SAS and ACS. For remote event debugging via Azure Service Bus, the only connection string currently supported is ACS. Follow the instructions in Service Bus Authentication and Authorization to get an ACS connection string for any new Service Bus namespace created after August 2014

Ref: https://msdn.microsoft.com/en-us/library/office/dn275975(v=office.15).aspx

You can use Microsoft Azure Powershell to setup an Azure Service Bus Namespace as below:

PS C:\> New-AzureSBNamespace rerdebug 'East US' -CreateACSNamespace 1

Which gives you the following output:

Name : rerdebug

Region : East US

DefaultKey : LlN5g56H1DViQ4eH/nEtE879MANXk+KuVQFX3e4Vk2M=

Status : Active

CreatedAt : 10/3/2014 5:33:38 PM

AcsManagementEndpoint : https://rerdebug-sb.accesscontrol.windows.net/

ServiceBusEndpoint : https://rerdebug.servicebus.windows.net/

ConnectionString : Endpoint=sb://rerdebug.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=LlN5g56H1DViQ4eH/nEtE879MANXk+KuVQFX3e4Vk2M=

Set the value for “Endpoint=” highlighted above as your connection string and you should be good to go!

When connected successfully, you will find the following in the Visual Studio output window:

“Services/RemoteEventReceiver1.svc has been registered on Microsoft Azure Service Bus successfully”

Note: If you find that debugger is properly attached but breakpoints are never hit, make sure that you are performing the action (adding list or list item) in the App Web, not the Host Web. Remote event receivers FAQ