Friday, July 11, 2014

Register remote event receiver (RER) with CSOM

I'm currently working on a provider hosted SharePoint 2013 app. The aim is to build a self provisioning app by making use of the client side object model  (csom).

In an old fashion way, provisioning of site columns, content types, lists... was done with declarative coding. Unfortunately, declarative host web provisioning isn't possible. Luckily for us developers, the OfficeAMS contributors are working hard on building nice extension methods to speed up SharePoint development. 

in the following example I'm provisioning the host web during the AppInstalled event.
  • creating a new list
  • binding the remote event receiver to the newly created list
The remote event receiver is a .svc service hosted on the remote web of the provider hosted app. In my example I'm using Azure.

In fact, binding the RER isn't rocket science, but since the ReceiverUrl property is set to the absolute address of the .svc we won't be able to debug this thing. If we want to debug a remote event receiver hosted on Azure we have to make use of an azure service bus.

This is why I'm using the #if DEBUG directives of visual studio. If in debug mode, I'm overwriting the absolute .svc url in the following format:
https://server.servicebus.windows.net/computer/account/obj/guid/EventReceiver.svc 

This raises the question, what are the computer, account and guid parameters in this URL? I figured out these values by opening the .debugapp package that is generated by visual studio during debugging.

While debugging you can find this package in the debug folder of your project.
Extract this .debugapp package and open the AppManifest.xml file in a text editor.
The InstalledEventEndpoint contains all the values your are looking for.


1 comment:

  1. Thanks Sander!
    Finding out the service bus url like this really helped me!

    ReplyDelete