SharePoint provides two types of add-ins (Previously Apps)
- SharePoint Hosted Add-ins: Used to deploy SharePoint resources like pages, lists, workflows, custom content types, list templates, Web Parts and so on. It cannot contain custom server side object model code but supports REST and JSOM.
- Provider hosted Add-ins: Used to deploy components outside the SharePoint Farm. It can include a web application, web service or database that is deployed outside SharePoint.
In this article series we will see how to deploy a provider hosted add-in to SharePoint Online in Office 365. Here the Website will be hosted in Azure and the App will be installed in SharePoint Online. Thus the core logic will be abstracted away from SharePoint farm. Upon opening the app in SharePoint Online, the redirection happens to the Website hosted in Azure. The article will be divided into 2 parts.
- Create, Configure and Deploy remote add-in web to Azure.
- Deploy add-in to SharePoint online.
Prerequisites
Ensure that you have the below subscription to get started with the development.
- Azure Subscription: The web site will be hosted in Azure. So ensure that we have an active Azure Subscription.
- Office 365 SharePoint Online Subscription: We will need a developer Site to which the app will be deployed.
Create, Configure and Deploy remote add-in web to Azure
Spin up Visual Studio and Select ‘SharePoint Add-in’ template.

Specify the SharePoint Online Developer Site URL and select Provider-hosted option. Click on Next.

This will open up the Office 365 authentication pop up. Enter the Office 365 credentials.

It will automatically select ‘SharePoint Online’ version. If not select it manually.

You can either proceed with web Forms or MVC Web Application. Here I am moving ahead with MVC.

Since we are deploying the Web to Azure, we will be making use of Azure Access Control Services (Known as Low Trust Authentication). If we were deploying the web to an on premise IIS server we could have used a signed certificate (known as High Trust).

Click on Finish. This will create the Project structure for us.

Thus you can see that there are two sections in the created solution structure below,
- OfficeProviderHostedAdd-in: it will be deployed to the SharePoint Online Site.
- OfficeProviderHostedAdd-inWeb: it will be deployed to Azure.

If we expand the Controller folder, we can see the controller files.

Within the Views Folder we can see the View file. We will be getting the current user name in the controller and will be displaying it using the view as shown below.


We can update the MVC logic as required in the Controller and View files. MVC implementation is similar to the .NET counterpart. Let’s see what we have to do to get the web site deployed into Azure. Right click the add-in web and select ‘Publish’.


















Guest UserPosted Mar 25, 2018, 11:35 AM
Very useful post! Can I ask you if this approach can be also used to deploy in azure a SharePoint Workflow Code Activity also including some code behind? I mean a new custom action to be used in SPD for a SharePoint online workflow
Vignesh ManiPosted Sep 29, 2016, 12:41 PM
Nice
Humayun Kabir MamunPosted Sep 28, 2016, 12:02 AM
Nice bro, waiting for Part 2...