This article will explain how to create and host your first provider-hosted app for SharePoint Online (Office 365 and SharePoint 2013 on premise).
Prerequisite
My Office 365 public site:
Office 365 site: just4sharing
Windows Azure Web site: myphapp.azurewebsites
Visual Studio 2012/2013
Step 1: Start a new Visual Studio Project, use the "App for SharePoint 2013" template as in the following:
Step 2: Select the Provider-hosted option for this example. In a Provider-hosted app, application resources will be deployed in a server outside the SharePoint environment.
Step 3: In the next step, select “Use Client secret (requires a SharePoint farm connected to ACS)”. We will be using the Access Control Service (ACS) available with Windows Azure for this example.
Step 4: Click "Finish" and the project is created for you by Visual Studio. You can see two projects created under the solution. The first project consists of just an app icon and AppManifest.xml that manages all the settings like start URL, permission, Query strings, Client ID, Tokens and so on.
Step 5: The next step is to register a new app using client Id and Client Secret.
- Go to the “/_layouts/15/appregnew.aspx” page of your SharePoint site (in my case, it is just4sharing-public.sharepoint.com) to generate the client Id and client secret id.
- Click on the generate buttons of Client Id and Client Secret to generate both.
Step 6: We need to fill in “App Domain” and “Redirect URL”. In fact, this is the website where the app is hosted. I am using Windows Azure to host my app. Let us go to the Windows Azure Management Portal and create a web site to host your app.
Step 7: I am done with my web site in Windows Azure. myphapp.azurewebsites
Step 8: As I said in the previous step, let us supply “Domain Name” and “Redirect URL” in the registration page.
Step 9: We are done with the registration process. Copy the Client Id and Client Secret to a safe place.
Step 10: The next step is to publish both projects separately. First, publish the app project as in the following:
Step 11: Create the publishing profile providing the Azure site name, Client Id and Client Secret as in the following:
Step 12: Click “Finish” to see the summary page as in the following:
Step 13: The output is a package file as shown in the following screen shot.
Step 14: Time to upload the package. Upload your custom package to the developer site. All steps are shown in the following screenshots.
just4sharing.sharepoint
Step 17: We are done with publishing and deploying.
Step 18: It is time to click on the app link.
Step 19: You are done! You get the URL: https://myphapp.azurewebsites.net/Pages/Default.aspx?SPHostUrl=https%3A%2F%2Fjust4sharing%2Esharepoint%2Ecom&SPLanguage=en-US&SPClientTag=0&SPProductNumber=16%2E0%2E2510%2E1211
Step 20: What you see is the template type of the SharePoint Site.
Step 21: Also this image would provide you some idea about AppManifest.xml as in the following:
I hope this helps, just leave a comment if it does.
just4sharing