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
- 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.
- Go to the following address, ~sitecollection /_layouts/15/appregnew.aspx. Then we will get the following window.
Fig: App Information
- 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.
- Provide your app with a name of your choice.
- 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.
- At position 4, as shown in the above figure, prove the App domain without HTTPS.
- 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.
- Now, again, go to your Azure portal and open the App service on which we were working previously.
Fig: App settings of the Azure App Service
- Select Application settings as shown in position 1and insert the ClientId and ClientSecrect here, as shown in position 2.
- 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.
Fig: Azure App Service Overview Window
- Now, open the event receiver solution in your Visual Studio.
- 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.
- From the ‘Overview’ tab of the App Service which here is My-Test-EventReceiver, download the "Publishing Profile" as shown in the photo above.
- Now, from your Visual Studio, select the Project web file and click the Publish option.
- Now, you will get a window as follows.
- 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.
- After uploading the Publish profile, click next as shown in the position 4. It will go to the “Connection” tab.
- Confirm that “Publish method” is selected as Web Deploy. Then, validate the connection and click Next.
- And from the next window, select “Release” and click “Publish” button.
- 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
- The Client app needs to deploy in App Catalog. And then, installed in the selected site.
- So, to deploy the client app in the App Catalog, we need to create the client app package.
- Click the event receiver’s app part and click Publish. The following window will open.
Fig: Package the Client App
- Here, click the "Edit" button which will open the window with the Client Id and Client Secret.
- Here, provide the Client Id and Client Secret which we already have at step 4. Then click Finish.
- 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.
- 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.
- 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”.
- A package file with “.app” extension will be created. Now, we have to deploy the app in our SharePoint App Catalog.
- After deploying the app in app catalog successfully, we can install the app on our site.
- Under Site contents of the selected site, we have to click “add an app” as shown in the figure below.
- 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.
- This page confirms that the deployment on both, Azure and SharePoint, ends have been successful. Congratulation the deployment process is fully complete.
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.