unh2xw
Last Updated: February 25, 2016
·
6.522K
· steveniseki
Stevenm

Create a provider hosted app for SharePoint Online

In Visual Studio 2013, Select New Project, then SharePoint 2013 App

What SharePoint site do you want to use for debugging your app

Enter your SharePoint Online dev site e.g.
https://mysite.sharepoint.com/sites/dev/

How do you want to host your app for SharePoint

select Provider Hosted

Specify the web project type

Select ASP.NET MVC Web Application, the Web Forms one didn't work for me, otherwise I would use it.

How do you want your app to authenticate

Use Windows Azure Access Control Service, assuming we are pointing to a provider hosted app in Azure here

Your app should now be created!

Set up your website in Azure

Set up your website e.g. testapp1.azurewebsites.net

Once created download the publishing profile in Azure for your site

Set up your App Secret and Id

Jump in to your SharePoint Online site

Navigate to the App Registration page for the site, which will set a new app id and secret.
https://mysite.sharepoint.com/sites/dev/_layouts/15/AppRegNew.aspx

Click Generate to create a new Client id and Client Secret. Then enter your domain name, this is your Azure website, but leave out the http protocol, and no backslash

<b>Client ID:</b> 43b81cd7-282b-4d35-bfc2-1e98c7cba94f

<b>Client Secret:</b> NJwk35grgxkjgCKfDacU9AMoHwpy/7CYlAagUZFHjAA=

<b>Title:</b> test app 1

<b>App Domain:</b> testapp1.azurewebsites.net

Now back in Visual Studio

<b>Note:</b> you have 2 projects, the top one is the SharePoint App and the bottom the website you will host in Azure.

Build and publish you Azure website

On the bottom project in Visual Studio

Jump into the web.config in your website project and update the app settings

<appSettings>
  <add key="ClientId" value="43b81cd7-282b-4d35-bfc2-1e98c7cba94f" />
  <add key="ClientSecret" value="NJwk35grgxkjgCKfDacU9AMoHwpy/7CYlAagUZFHjAA=" />
</appSettings>

Build the project, then click Publish from the Top Menu in VS to build the site.

Click the drop down, create a new profile, and browse to find your publishing profile you saved locally from Azure management center.
<b>Note:</b> I had to install web deploy 3.5 to publish the site.

Build your SharePoint app

Now in the top project, the SharePoint app

In the AppManifest.xml file enter the app ID value as the ClientId

<AppPrincipal>
<RemoteWebApplication ClientId="a044e184-7de2-4d05-aacf-52118008c44e"/>
</AppPrincipal>

In the AppManifest.xml file enter the Start Page element to be the same as you app domain,
Which is your azure app, but add in <b>https://</b>

<StartPage>https://testapp1.azurewebsites.net?{StandardTokens}</StartPage>

msdn Reference

Say Thanks
Respond