The official website of Bipul Raman

Developing SharePoint App on Office365 : Part 3 - Provider hosted Apps

No comments
This SharePoint App is actually an ASP.Net application hosted on the different server (outside SharePoint environment) which is accessible through Site Contents of the Site collection.

Creating Provider Hosted App

  1. Create a new project by selecting this option as described in screenshot: 
  2. Enter your SharePoint Site URL and select hosting as Provider-hosted as described in below screenshot: 
  3.  Select the appropriate SharePoint version
  4. Select type of application you want to create. It can be any one of the following:
    a.    ASP.Net Web Forms Application
    b.    ASP.Net MVC Web Application
    Here we are proceeding with a very simple ASP.Net MVC Application.
  5.  Click on next and select ‘Use Windows Azure Access control service’ and then click on Finish.
  6.  A login box will appear asking to Sign-In to Office 365 Account. Follow that and login using that. It will create a connection of your project to your SharePoint online site on office 365
  7.  Code your MVC appliocation end using C# (CSOM) and JavaScript (JSOM)
  8. Open AppManifest.xml and set the permission as described in screenshot. Permission may be anything e.g. - read, write, full control based on the requirement of your app
  9. Right Click on solution and click on “Deploy Solution”
  10. Click on “Debug” option to run the Application on localhost. A new tab will be opened in the browser and it will be asking permission to trust the application. Click on “Trust It” and move ahead 
  11. Your SharePoint Hosted App is ready to use on localhost for debugging

Deployment Steps:

  1. We are assuming to make a deployment of App on Azure. So first we need to create a blank website on Azure. That would be something like this -
  2.  There will be two part in the solution. The first/upper part will be for SharePoint App and the second one will be ASP.Net web app.
  3.  Register your app with AppRegNew.aspx (i.e. the page which can be found at /_layouts/15/appregnew.aspx). Click on Generate button to get Client ID and Client Secret. Make a note of all the info you save on this page
  4. Update the new Client ID and Client Secret in AppMenifest.xml and web.config
  5. Select the ASP.Net Project of the Provider hosted app solution, Right click and Publish
  6. Select Microsoft Azure Web Apps to publish
  7. A login page will appear. Enter the same credential which you are using for SharePoint on Office 365. 
  8. Select the Web App which you have created on Azure, and Publish. 
  9. Right click on SharePoint App Project of the solution of Provider hosted app.
  10. Cick on Edit option and fill the client ID and Client Secret 
  11. Lastly, Click on Package the App
  12. After publishing, you will get a .app file. example:
  13. Open Site contents and go to Apps in Testing list. Upload the app package (*.app file) and Deploy.
    ** We are using this for testing out app before releasing it to all users. Please Note: 'Apps in Testing' list is available only in Developer Site Template.
  14. Alternatively or for release purpose you can upload it in 'Apps For SharePoint' list in App Catalog Site collection. App Catalog site collection can be configured from Central Admin >> Apps. Once you upload app in 'App For SharePoint'. For App installation , Go to Site Content >> Add an App >> Select the App and add it.

  15. Your Provider Hosted App is ready to use.

No comments :

Post a Comment