Calling my .SVC which is hosted inside Azure App Service using Https will return “http 404”

john john 941 Reputation points
2020-02-11T16:16:28.663+00:00

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:-

2882-22222222.png

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.:-
2921-3333333333.png

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:-

2931-4444444444444.png

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.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,867 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. brtrach 251 Reputation points
    2020-03-19T08:41:52.597+00:00

    If you still require assistance, I would suggest posting your question here as this does not seem to be an issue being caused by the underlying web app. We've worked with others who were successfully able to use https with the web apps platform for their SharePoint RER.

    While I'd say you'd have better luck talking to someone on the SharePoint side, I'd still recommend making sure that you have configured the app domain, redirect URI, and add-ins registration to explicitly use HTTPS as all of these have fields that require the URL.

    Also, storing application secrets in the web config file is considered a security risk as anyone with dev access to your project can see and edit the secrets. The best practice is to store these secrets in Azure Key Vault and use RBAC to restrict access. More on that here.

    0 comments No comments

  2. Marco Antonio Garcia 1 Reputation point
    2020-09-11T17:19:03.42+00:00

    According to what is published wcf-webservice-doesnt-respond-via-https-hosted-microsoft-azure

    I needed to specify the security mode in the webHttpBinding tag, and HTTPS worked! Check out my web.config below, and let me know if this helps you too.
    Happy coding everyone 🙂

    Web.Config
    <?xml version="1.0"?>
    <configuration>
    <system.web>
    <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
    <bindings>
    <webHttpBinding>
    <binding name="HttpsConfiguration">
    <security mode="Transport" />
    </binding>
    </webHttpBinding>
    </bindings>
    <services>
    <service behaviorConfiguration="Service1Behavior" name="WcfService1.Beringer.BERWeb">
    <endpoint address="" behaviorConfiguration="JSONEndpointBehavior" binding="webHttpBinding" bindingConfiguration="HttpsConfiguration" name="RESTEP" contract="WcfService1.Beringer.IBERWeb" />
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="Service1Behavior">
    <serviceMetadata httpGetEnabled="true"
    httpsGetEnabled="true"/>
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
    <behavior name="JSONEndpointBehavior">
    <webHttp />
    </behavior>
    </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
    </system.webServer>
    </configuration>

    0 comments No comments