Step By Step- SharePoint 2013 Provider Hosted App - Azure Hosting

Here In this blog on SharePoint 2013 Provider hosted app will try to cover each and every steps to create provider hosted app.

1. Open Visual Studio 2012.



2. Click on New Project -> Select SharePoint template 


3. Visual studio will prompt to add Office 365 SharePoint Site you are using and select the Provider-hosted from dropdown list.



4.  On selection of Provide Hosted, click Next you will be prompted with following screen.
Select use a client secret option.



5. Now, Click on Finish. visual studio will take some time to prepare solution.



6. Solution has been created with two projects, looks like below image,


7.  App project will be deployed to SharePoint. And AppWeb project will be .Net Web Application. 


8. Now lets Deploy Provider-Hosted App to SharePoint.
 here, I am adding some sample test text in default.aspx as per below code,

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
<h2>First Azure Page.</h2>     </div>
    </form>
</body>
</html>

9.  Check the code behind of default.aspx contains code to get Accesstoken from TokenHelper.cs

10. Now,


11. Copy the App Id to AppManifest.xml file in your Visual Studio project. will look like below, you need to modify it by right click and view code.

<?xml version="1.0" encoding="utf-8" ?>

  <Properties>
    <Title>TestApp</Title>
    <StartPage>
http://anuja-bhojani.azurewebsites.net/Pages/Default.aspx?{StandardTokens}</StartPage>
  </Properties>
  <AppPrincipal>
    <RemoteWebApplication ClientId="f3bdddd6-65a1-5g89-acd5-655dddddd94c" />
  </AppPrincipal>
</App>

12. We have to add this to Web.config also.

<appSettings> 
  <add key="ClientId" value="f3bdddd6-65a1-5g89-acd5-655dddddd94c" />
 <add key="ClientSecret" value="damw+Svgx3K999556744332999zmmGmI1C6HKWWKbGU=" />
 
</appSettings>

13. Last step, need to give permission on App, Due to that we can interact with SharePoint. Please look the image below.


14. We are good to go now, Right click on app project -> Publish

15. Select Publish Profile from drop down, if not yet downloaded, click on import and from azure site download it.



16. Click Next, you will get automatically feel up ClientID and Secret, Just press Finish.


17. You will see Page where you need to click on "Trust App". Will redirect to azure site where will get our test message.

We are done with simple provider hosted app!

For the advance operation list read and write operation:
http://anujabhojani.blogspot.in/2013/06/provider-hosted-app-azure-and-read.html

Comments

  1. Nice and Simple Article Anuja.. Thanks it helped me.

    While following your article, i didnt get how to publish the Web project on azure site i have created. After clicking on Publish on web project and choosing web deploy option, a number of parameters are being asked... what to fill for that .. can you explain with some screenshot.

    ReplyDelete
    Replies
    1. I am glad that this article helps you, I think you are doing publish on wrong project, it should be on app project, which should redirect you to select the publish profile.

      Delete
  2. CloudAppsPortal offers free SharePoint sites that are fully functional. www.cloudappsportal.com believes in encouraging users to learn and adopt SharePoint technology for individual, consulting or small and medium business uses.

    ReplyDelete

Post a Comment

Popular posts from this blog

Search Query by ContentType name issue

SharePoint 2013 List CRUD operation using Angular and REST API

Search Result Webpart,Filter result If QueryString is present in URL