Deploy SharePoint Remote Event Receiver To Microsoft Azure

This article will help even a beginner to deploy a SharePoint Remote Event Receiver easily to Microsoft Azure.

Remote Event Receiver

A remote event receiver is a web service added to a web application to handle the remote events as specified. Just like the traditional event receiver, the remote event receiver works in the SharePoint as same. With a synchronous or an asynchronous event handler, the event can be triggered on the SharePoint site. And a web service calls the server-side code wherever it is deployed. The Server-side code for apps can be installed by any web server in on-premise or online.

In this article, we will discuss the deployment process of the Remote Event Receiver to Microsoft Azure, and the installation process of the client app to SharePoint site. The step by step procedure with the relative figure is given below.

Steps to deploy Remote Event Receiver to Azure

  1. First, we have to register the client app in the selected site (from where the event receiver will be triggered) and generate the client app authentication.

  2. Go to the following address, ~sitecollection /_layouts/15/appregnew.aspx. Then we will get the following window.

    Azure
    Fig: App Information

  3. Click the button generated beside the Client Id to generate the client id, as shown in position 1 and same for client secret at position 2.

  4. Provide your app with a name of your choice.

  5. Provide the Azure App Service URL which the app service has already created to host this event receiver. Copy the App domain as shown (below) in the “Fig: Azure App Service Overview Window” at position 2.

  6. At position 4, as shown in the above figure, prove the App domain without HTTPS.

  7. At position 5, provide the app domain with https:// as prefix and click the "Create" button. The App registration key with the provided app domain will be registered on the working site.

  8. Now, again, go to your Azure portal and open the App service on which we were working previously.

    Azure
    Fig: App settings of the Azure App Service

  9. Select Application settings as shown in position 1and insert the ClientId and ClientSecrect here, as shown in position 2.

  10. Provide “ClientId” string in the key portion and provide your Client Id as I have provided mine “b4f974fb-63ff-40d0-b5ba-4d323fcad9bf” in the value. And do the same for client secret. Then save it.

    Azure
    Fig: Azure App Service Overview Window

  11. Now, open the event receiver solution in your Visual Studio.

    Azure

  12. Open AppManifest.xml file under the app part of the event receiver. And select “Site Collection” and “Web” in the Scope column and select “FullControl” as their permission.

  13. From the ‘Overview’ tab of the App Service which here is My-Test-EventReceiver, download the "Publishing Profile" as shown in the photo above.

    Azure

  14. Now, from your Visual Studio, select the Project web file and click the Publish option.

  15. Now, you will get a window as follows.

    Azure

  16. So, now, select the profile. Then, click on Import portion in position 2 and then select the downloaded profile which we have already downloaded from our Azure portal.

  17. After uploading the Publish profile, click next as shown in the position 4. It will go to the “Connection” tab.

    Azure

  18. Confirm that “Publish method” is selected as Web Deploy. Then, validate the connection and click Next.

  19. And from the next window, select “Release” and click “Publish” button.

  20. Visual Studio will process the rest and deploy the event receiver in the selected App service in the Azure.

Install the App part on SharePoint Site

  1. The Client app needs to deploy in App Catalog. And then, installed in the selected site.

  2. So, to deploy the client app in the App Catalog, we need to create the client app package.

    Azure

  3. Click the event receiver’s app part and click Publish. The following window will open.

    Azure
    Fig: Package the Client App

  4. Here, click the "Edit" button which will open the window with the Client Id and Client Secret.

    Azure

  5. Here, provide the Client Id and Client Secret which we already have at step 4. Then click Finish.

  6. Now, the previous window will be visible as in “Fig: Package the Client App”. Then, click “Package the App” button as shown in position 2 (Fig: Package the Client App). Then, a new window will open as below.

    Azure

  7. Here, in the first text box, the App Service Domain URL will be already there. Confirm that the prefix is https://, not http://. The Client id will be already provided so just click Finish.

  8. The Package will be created and the output will be saved in “<Folder path>\<Solution Folder>\<Project>\bin\Debug\app.publish\1.0.0.0”.

    Azure

  9. A package file with “.app” extension will be created. Now, we have to deploy the app in our SharePoint App Catalog.

  10. After deploying the app in app catalog successfully, we can install the app on our site.

    Azure

  11. Under Site contents of the selected site, we have to click “add an app” as shown in the figure below.

  12. Then, we have to install the app we install other apps on SharePoint. After completing the installation, we can click on the app icon which will open the event receiver azure app domain page with the current site list.

    Azure

  13. This page confirms that the deployment on both, Azure and SharePoint, ends have been successful. Congratulation the deployment process is fully complete.

Conclusion

The article is a bit lengthy as I have tried to describe each and every step with an image. I have not found any completed article to deploy SharePoint Remote Event Receiver in Microsoft Azure. So, I have tried to write this article in a way that even a beginner can deploy it easily with the help of this. Please give your suggestions if you think any portion can be described more simply.