Step by Step Procedure to Create a Low Trust Provider Hosted App for Office 365 and Host the AppWeb in Azure WebSite

Sathish Nadarajan
 
Solution Architect
August 15, 2016
 
Rate this article
 
Views
11395

In the earlier article, we saw how to create a high trust Provider Hosted App Long time back. Now, let us see how to create a Low trust Provider Hosted App for Office 365, in fact Office 365 accepts only Low Trust Apps alone and Host the App web in Azure WebSite.

The Pre-requires are as follows.

1. Office 365 Subscription

2. Azure subscription

3. Visual Studio 2015 (Professional/Community/Enterprise Edition)

With the pre-requisites ready, let us start with step by step

1. Login to the Office 365 and Create a Developer Site.

clip_image002

2. Login to Azure and Create a Web Application. To Create a Web Application, please REFER THE LINK HERE

3. In our case, I have created the Web Application Name as “O365PHA”

4. The URL will be http://o365pha.azurewebsites.net

5. Now, come back to the O365 Site. i.e., the Developer site, which we created.

6. Open the Page, https://****.sharepoint.com/sites/DeveloperSite/_layouts/15/appregnew.aspx

clip_image004

7. Generate the ClientID and Client Secret ID. Give the Title, AppDomain and Redirect URI as below.

clip_image006

8. Click on Create.

clip_image008

9. Copy the Information (Client ID, Client Secret ID etc., in a NotePad)

10. Now, open the Visual Studio 2015.

11. Create a New Project.

clip_image010

12. Enter the Developer Site URL and Select Provider Hosted App.

clip_image012

13. On Click of Next, the Credentials Window will be popup. Enter the Credentials.

clip_image014

14. Once, login, the below window will appear. Select SharePoint Online on it.

clip_image016

15. Choose the WebProject Type based on our requirement.

clip_image018

16. Select the Authentication Settings. Use the Windows Azure Access. Because Office 365 can only be Low Trust. Using Certificate is a high trust App.

clip_image020

17. Project will be Created.

clip_image022

18. Once, the project Created, the solution structure will be as follows.

clip_image024

19. Open the Web.Config and Update the ClientID and Client Secret with the Values which we created in the earlier steps.

clip_image026

20. Update the AppManifest.XML as below.

 <?xml version="1.0" encoding="utf-8" ?>
 <!--Created:cb85b80c-f585-40ff-8bfc-12ff4d0e34a9-->
 <App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest"
      Name="Office365PHAAzureApp"
      ProductID="{35f05212-44de-4a8a-b3b7-66cdbfff2485}"
      Version="1.0.0.0"
      SharePointMinVersion="16.0.0.0"
 >
   <Properties>
     <Title>Office365.PHA.AzureApp</Title>
     <StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
   </Properties>
 
   <AppPrincipal>
     <RemoteWebApplication ClientId="29b7b92a-2e2c-42b1-a4bc-1a16e01736c5" />
   </AppPrincipal>
 
   <AppPermissionRequests AllowAppOnlyPolicy="false">
     <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />
   </AppPermissionRequests>
   
 </App>
 

21. Now, we are done with the steps. We need to publish the AppWeb to the Azure Web App Created.

22. Right Click on the AppWeb Project. Click on Publish.

clip_image028

23. Click on “Microsoft Azure App Web”

clip_image030

24. On the next Screen, Login to the Azure account and select the WebAPP which we created.

clip_image031

25. On Click OK, the publishing Profile will be automatically downloaded and populated.

clip_image033

26. Validate Connection – After getting the Success, Click on Next.

27. On the next screen, I am selecting Debug option. In later we are going to see, how to debug the AppWeb Also. But not in this article.

clip_image035

28. After the Start Preview, the list of files, which are going to be deployed is shown as below.

clip_image037

29. Click on Publish. We are done. Successfully published.

clip_image039

30. Now, go back to Azure Web Site and make the Configuration Changes.

clip_image041

31. Click on Configure Tab.

32. Scroll down and Enter the AppSettings as shown below.

clip_image043

33. Click on Save at the Bottom.

34. Now, we will publish the APP project into SharePoint Office 365.

35. Let us publish the APP Project to the File system and upload the same to AppCatalog Site. To know more about the creation of AppCatalog Site, REFER HERE.

36. Now, coming back to Visual Studio. Right Click on the APP Project. Click on Publish.

clip_image045

37. The Publish Screen will appear as below.

clip_image047

38. On the Current Profile, there is a warning Symbol. Click on Edit and Enter the Client ID and Client Secret Properly.

clip_image049

39. Now, the Warning symbol has gone.

clip_image051

40. Click on “Package the app” and Enter the URL with HTTPS and the Client ID.

clip_image053

41. App is successfully packaged.

clip_image055

42. We will get the .APP File in the bin\debug\app.publish\version\ Folder.

43. Upload the APP file into AppCatalog Site Manually.

44. In My Case, the AppCatalog Site is something like https://sppalsmvp.sharepoint.com/sites/AppCatalog/

45. Go to “Apps for SharePoint” List.

clip_image057

46. Upload the new APP File here.

clip_image059

47. The AppLoaded APP will be something as below.

clip_image061

48. Now, come back to our Developer Site. Go to “Site Contents”

clip_image063

49. Click on “Add an APP”.

50. Add the “APP from your Orgnization”

clip_image065

51. Trust The App.

clip_image067

52. The App will be listed on the ViewLsts.aspx

clip_image069

53. Launch the App. We will get the App Launched.

clip_image071

54. The Name of the Site is displayed.

Though it is a bit very lengthy, but I wanted to cover this topic in detail as much as I can.

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment