1

I am developing a remote event receiver for our SharePoint online dev site. i followed the following steps:-

1- As mentioned in this link https://derekgusoff.wordpress.com/2017/11/08/remote-event-receivers-youre-all-doing-it-wrong/ i created a new asp.net web application inside VS 2019 + i add a WFC service to it.

2- Inside the service i added the following test code, to update the item title, as follow:-

public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {      
            SPRemoteEventResult result = new SPRemoteEventResult();
            //if using App Only Context, use this method, and make sure ClientId and ClientSecret are specified in AppSettings
            using (ClientContext context = Helpers.GetAppOnlyContext(siteUrl))
            {                  
                result.ChangedItemProperties.Add("Title", "After adding");
                result.Status = SPRemoteEventServiceStatus.Continue;
            }          
            return result;  
        }

3- i run the ngrok to debug the RER:-

Run ngrok command :- ngrok --http-header=rewrite 53938

4- i register the RER inside the Dev site @/sites/dev2/_layouts/15/appregnew.aspx

5- i update the web.config with the generated clientId and clientsecret from step number 4.

6- i Add the RER, using this power-shell command:

Add-PnPEventReceiver -List "12" -Name "TasksRER" -Url http://4f9922f3.ngrok.io/service1.svc -EventReceiverType ItemAdding -Synchronization Synchronous

7- i add the app permission using this sharepoint admin site url https://***admin.sharepoint.com/_layouts/15/appinv.aspx, as follow:-

<AppPermissionRequests AllowAppOnlyPolicy="true">
 <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
</AppPermissionRequests>

8- i run the VS project and the RER worked well..

9- now i wanted to deploy the RER to azure >> so i create a new azure web app >> generate a zip file for the project inside VS >> and deploy the zip inside the azure web app using kudu drag/drop, and i can access the service inside azure as follow:-

enter image description here

10- i re-register the RER using the azure url instead of the ngrok url, as follow:-

Remove-PnPEventReceiver -List 12 -Identity TasksRER

Add-PnPEventReceiver -List "12" -Name "TasksRER" -Url https://****.azurewebsites.net/service1.svc -EventReceiverType ItemAdding -Synchronization Synchronous

but when i add a new item, nothing happen, where seems the RER did not get fired. so can anyone advice what might be the problem?

EDIT

here is a screen shot for the appinv:-

enter image description here

EDIT-2

I download the eventlog.xml from Kudu, and i can see this error inside it:-

System.Web.HttpException (0x80004005): The service '/service1.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/service1.svc' does not exist. at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity) at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)

But i am not sure why it is saying service1.svc does not exists. as inside kude i can find it as follow:- enter image description here

Also as i mentioned above if i navigate to @ https://**azurewebsites.net/service1.svc, i will get the service as follow:- enter image description here

  • 1
    Have you updated the App Registration? Specifically the domain and Redirect Url? – Ciamas Jan 14 at 12:37
  • 1
    Have you tried to debug it remotely? Do you know if the requests are reaching the server? – Ciamas Jan 14 at 12:46
  • 1
    There is Requests diagram in App Service Overview in Azure Portal. Please make sure to wait a bit. It is not being updated instantly. – Ciamas Jan 14 at 12:52
  • 1
    The easiest way would be to add some logging or to debug remotelly. A basic example how to setup log4net stackoverflow.com/questions/25901782/logging-on-azure You can access the Kudu Console with yourAzureDomain.SCM.azurewebsites.net and then access the file system from the Debug Console on the top. You can also remotelly debug the App from Visual Studio. – Ciamas Jan 14 at 13:53
  • 1
    Forgot to mention the eventlog.xml. Navigate to Kudu Console, open the Debug Console ( no matter which ), open the LogFiles directory. There you will finde the file. – Ciamas Jan 14 at 14:11
0

404 (not found) can sometimes be related to permissions. Rather than say "access denied", and give away the fact that something exists, it just says "I dunno what you're talking about, nobody with that name here".

Point being, SharePoint is making a request to your azure svc, which means it needs access to call the azure svc. I'm not sure what "account" it's using, but perhaps the logs would indicate the user and you could ensure that user is granted explicit permissions to the svc?

Either that, or allow anonymous on the svc, but that's probably not a good idea. Maybe just to test and verify that's the problem?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.