Working with Provider hosted Apps on SharePoint Online

Apps are standalone application that solves business need. Microsoft recently renamed apps to add-ins.

According to app hosting, apps are divided into three types,

1. SharePoint Hosted apps

2. Provider Hosted Apps

3. Auto hosted – combination of these two.

This article is going to concentrate on Provider hosted app with SharePoint 2013 Online.

Provider hosted app is used for reusing existing .Net applications or where security is a concern. Because in this application, hosting is done in the outside SharePoint environment.

Provider Hosted App Flow
Basically, Provider hosted App gets divided into two parts. First is App, another is AppWeb.

App is the .app file which we add in AppCatalog site to install on SharePoint sites and AppWeb is the actual solution where logic & configurations resides which we host on hosting environment.

If you are coming from On-premise background, just for information, onlineprovider hosted app configuration process doesn’t need to go through certification authorization process.

Let’s start with creating Provider hosted app on Dev machine-

1. Open Visual Studio 2013 as Administrator (Make sure, you run it as administrator as it would through error later while deployment)

I. Navigate to file > New > Project

II. Under Installed > Visual C# > Office/SharePoint > Apps > App for SharePoint


III. Add App name and select ok.

IV. Add site url where app is to be installed. Select Provider hosted app option. Click next.


V. Add username and password associated to site url in pop up. Click Next.


VI. Select any of the option as per requirement. Click Next.


VII. Click Finish. Application should get added in Solution explorer.



Now, before we proceed with this solution, there are couple of activities needed to be perform for App authorization. Let’s do that.

2. Register App

I. Navigate to SiteUrl/_layouts/15/appregnew.aspx

Add details as below,

i. Client Id – Click generate.

ii. Client Secret – Click generate.

iii. Title – Add this as your application name.

iv. App Domain – This is a domain where we host provider hosted App’s Appweb. This value can be taken from navigating to > app services > Newly created Web app (where we will host app web) > In right panel – select URL. Remove https://. Remaining field will be your app domain. Add this remaining field in App Domain.

v. Redirect URI – This is a provider hosted App’s redirection URI. This value can be taken from navigating to > app services > Newly created Web app (where we will host app web ) > In right panel – select URL. Add this URL in this field.

vi. Click Create.


Make a note of all the details, as later we will need this.


3. Let’s get started with Visual studio.

There are two ways to run provider hosted app,

I. Using Visual Studio – This can be used for development purpose, debugging and on developer site. If you are working with team site, this won’t work. Visual studio deployment doesn’t need to register app mentioned in above step as it does app authorization by its own. Every time you deploy through visual studio client id gets changed.

II. Using App Catalog

i. Navigate to Solution explorer. Under Appweb, open Web.config file.

ii. Add client id noted in above step.

iii. Add client secret noted in above step.


iv. Under App, click AppManifest.xml > Permissions

v. Check Allow the app to make app only calls, depending on your requirement.

vi. Under scope, give required permissions to app. For every individual, this permissions will differ according to what actions app is going to perform.

In my case, I was trying to create site on tenant hence I had to give tenant level permission to App. Also, in one scenario, I was working with user profiles, so I had to give social level permissions.

Similarly, site collection or web level permissions can be given.

vii. Right click on AppManifest.xml > View Code. Under AppPrinciples add client id used in above steps.


viii. Here, you can also see Permission Request XML  section in AppPermissionRequests. Make a note of it.

Packaging app

ix. Right click on app. Select Publish. Under current profile select <new>.

x. Browse publishing profile of your web application where app is going to be hosted.

Publishing profile can be downloaded from, > app services > your newly created Web app >
Right Click > get Publish profile

xi. Click Next. Add client ID, Client secret used in above steps. Click Finish.

xii. Now select. Package the app. App will be get packaged

Deploying app in App catalog

xiii. Navigate to App catalog site

xiv. Navigate to App in SharePoint link from the left panel on App catalog site.

xv. Select upload. Browse to the path where .app files are kept.

xvi. Select packaged .app file, click OK. App should get added in list.

4. Giving permission to Registered App

For this, navigate to TenantSite/_layouts/15/appinv.aspx.

i. Add App id as Client ID used in above step.

ii. Click the lookup button. All details will be populated same as above step.

iii. In Permission Request XML section, add AppPermissionRequests section copied in above step this. It should look like –

iv. Click Create.

v. On successful creation, click Trust.

This step can be repeated for root site as well depending on requirement.

5.  Deploying AppWeb on Azure

i. Navigate to solution explorer. Right click on App web. Select Publish.

ii. Publish web pop up will get displayed, where you will see publishing
profile mapped in above step. In case if you won’t, select profile and

iii. Under connection, validate connection.

iv. Click Next. Again Next. Click Publish.

v. App web should get published in Azure.

6. Installing App on Targeted Site

i. Navigate to targeted site.

ii. Navigate to site contents. Click add an app. In search field, find an app. App should come below in suggestion.

iii. Now double click the app. Trust the app and app should get installed on site in few minutes.

iv. Click the installed app. App should run without any error.

If this blog post helped you, please let me know 🙂

4 thoughts on “Working with Provider hosted Apps on SharePoint Online”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top