I am working on a remote event receiver inside our SharePoint online root site collection (Where i am following the steps mentioned in this link https://derekgusoff.wordpress.com/2017/11/08/remote-event-receivers-youre-all-doing-it-wrong/), which worked well locally since i use http, but when i deploy it to azure the remote event receiver did not have any effect.
Here are the steps i followed for the deployment:-
0- I create a new asp.net web application + i add WFC to it.
1- I generate the client and secret id, using this url https://****.sharepoint.com/_layouts/15/appregnew.aspx for my SharePoint site collection.
2- Then i access the app from the SP admin center site @ https://***-admin.sharepoint.com/_layouts/15/appinv.aspx
3- I add the the app permission.
4- Inside Visual Studio 2019 >> i added the client id and client secret inside web.config >> i publish the project to my c drive:-
5- then i zip the generated files "bin.zip".
6- i created a new web app inside azure named TGroupPUSRER, as follow:-
7- after that i publish the zip file to azue using this command:-
az webapp deployment source config-zip --resource-group "PUS" --name "TGroupPUSRER" --src "C:\pus\bin.zip"
8- i add the RER using these 2 command:-
Add-PnPEventReceiver -List "Project System" -Name "PUSRERupdating" -Url https://tgrouppusrer.azurewebsites.net/rer.svc -EventReceiverType ItemUpdating -Synchronization Synchronous
Add-PnPEventReceiver -List "Project System" -Name "PUSRERupdated" -Url https://tgrouppusrer.azurewebsites.net/rer.svc -EventReceiverType ItemUpdated -Synchronization Asynchronous
but when i edit any of the items inside the "Project System" list, the RER will not have any effect.
I checked the logs and i can find the following exception, which is mentioning that my rer.svc can not be found:-
System.Web.HttpException (0x80004005): The service '/api/vfs/site/wwwroot/RER.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/api/vfs/site/wwwroot/RER.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)
Although when i access the service from my browser @ https://tgrouppusrer.azurewebsites.net/rer.svc i got this page, which mean the srv does exists.:-
now i enable the application logs for the azure web app >> and once i update a list item the application logs will show this error :-
The default timeout is 2 hours. Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds).HTTP Error 404.0 - Not FoundThe resource you are looking for has been removed, had its name changed, or is temporarily unavailable.Most likely causes:The directory or file specified does not exist on the Web server.The URL contains a typographical error.A custom filter or module, such as URLScan, restricts access to the file.Things you can try:Create the content on the Web server.Review the browser URL.Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:Module ManagedPipelineHandlerNotification ExecuteRequestHandlerHandler svc-Integrated-4.0Error Code 0x00000000Requested URL https://tGroupPUSRER:80/rer.svcPhysical Path D:\home\site\wwwroot\rer.svcLogon Method AnonymousLogon User Anonymous
More Information:This error means that the file or directory does not exist on the server. Create the file or directory and try the request again.View more information »Microsoft Knowledge Base Articles:
2020-02-03 21:45:22 tGROUPPUSRER POST /rer.svc X-ARR-LOG-ID=666b6779-fca6-4a90-8e94-9c695780dae4 443 - 40.108.180.36 - - - tgrouppusrer.azurewebsites.net 404 0 0 372 8227 19
2020-02-03 21:45:22 tGROUPPUSRER POST /rer.svc X-ARR-LOG-ID=42637d01-4bdb-4345-843b-89713a935aa2 443 - 40.108.180.36 - - - tgrouppusrer.azurewebsites.net 404 0 0 372 8455 19
2020-02-03 21:45:33 tGROUPPUSRER POST /rer.svc X-ARR-LOG-ID=8696a37b-6881-4eb1-9110-701d4bddaeb5 443 - 40.108.180.145 - - - tgrouppusrer.azurewebsites.net 404 0 0 372 8187 46
2020-02-03 21:45:33 tGROUPPUSRER POST /rer.svc X-ARR-LOG-ID=8779cafe-fbc4-4094-9ff4-9fa10b884875 443 - 40.108.180.145 - - - tgrouppusrer.azurewebsites.net 404 0 0 372 8415 21
2020-02-03 21:45:43 ~1tGROUPPUSRER GET /api/commandstream/ping shell=CMD&_=1580765141131&X-ARR-LOG-ID=d4e5e91c-1062-44d4-9e94-e93cf6911357 443 - 165.225.80.94 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/79.0.3945.130+Safari/537.36 ARRAffinity=e8228ec522d0bb0cde1261622aaf3fb9855105fb7485023fe847aa1a3a4e8100 https://tgrouppusrer.scm.azurewebsites.net/DebugConsole tgrouppusrer.scm.azurewebsites.net 200 0 0 513 1582 0
2020-02-03 21:45:43 ~1tGROUPPUSRER GET /api/filesystemhub/ping _=1580765141130&X-ARR-LOG-ID=7e168704-35a9-4d2f-a4f9-b9e6f702a7ff 443 - 165.225.80.94 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/79.0.3945.130+Safari/537.36 ARRAffinity=e8228ec522d0bb0cde1261622aaf3fb9855105fb7485023fe847aa1a3a4e8100 https://tgrouppusrer.scm.azurewebsites.net/DebugConsole tgrouppusrer.scm.azurewebsites.net 200 0 0 513 1552 0HTTP Error 404.0 - Not FoundThe resource you are looking for has been removed, had its name changed, or is temporarily unavailable.Most likely causes:The directory or file specified does not exist on the Web server.The URL contains a typographical error.A custom filter or module, such as URLScan, restricts access to the file.Things you can try:Create the content on the Web server.Review the browser URL.Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:Module ManagedPipelineHandlerNotification ExecuteRequestHandlerHandler svc-Integrated-4.0Error Code 0x00000000Requested URL https://tGroupPUSRER:80/rer.svcPhysical Path<
Here is a screen shot of the above error when i save it a html:-
Finally after doing many tests I found an important note, is that if i register the Remote Event Receiver using http instead of https, as follow:-
Add-PnPEventReceiver -List "Project System" -Name "PUSRERupdating" -Url http://tgrouppusrer.azurewebsites.net/rer.svc -EventReceiverType ItemUpdating -Synchronization Synchronous
Add-PnPEventReceiver -List "Project System" -Name "PUSRERupdated" -Url http://tgrouppusrer.azurewebsites.net/rer.svc -EventReceiverType ItemUpdated -Synchronization Asynchronous
the Remote Event Receiver will work well... so can this give an indication what is the problem.