Responsive Ads Here

Monday, November 3, 2014

How to publish provider hosted app in SharePoint online


In SharePoint 2013, Microsoft has introduced apps. we have three types of methodologies to host the apps in SharePoint.

SharePoint hosted app:

This type of App lives inside SharePoint. There is not code running on the server. All code must run in the client. This will have .aspx page but lots of JavaScript code that will implement the logic via client side script and service calls.

Provider-hosted apps comes under cloud hosted app. These apps hosted outside of SharePoint server. Since its hosted outside of SharePoint server you have the freedom to develop an app using any language like PHP, Java or .Net. You can write server side code here which will communicate with SharePoint server. Here it will use OAuth protocol for authentication mechanism.

Provided hosted app enables developer to define its own infrastructure which may be a dedicated server or may be a cloud server provided by providers like Amazon.
As we know provider hosted app we can deploy both in on premises and SharePoint online. Let us discuss how to deploy the app in SharePoint online. in my next post we will discuss how to host the app in on premises.

When we are creating provider hosted app in VS, it will create two projects app and appweb. Before starting creation of provider hosted app we need to have SharePoint Online and Windows azure account.

In my SharePoint online site, I have created one site collection with developer site template.

1.       Create a new project in VS with the template App for SharePoint, give the name of the project and click on OK. In this screenshot I am creating a project with the name SampleProviderhostedapp.

App For SharePoint

2. Click on OK it will prompt for the site name where you want to debug the provider hosted app. I have given my SharePoint online developer site name and selected the provider hosted app in the section how do you want the host the app.



3.     3. Click on next we will get the window which will ask which type of project you want to create. We can create the project in Asp.Net Web forms application or ASP.Net MVC application. I am going with the option ASP.Net Web forms application.

Web Project Selection

3.     4.Click on Next we will get a window to where we can configure the authentication settings, I am going with the option with windows Azure Control service and click on Finish.

Authentication Settings

3.     Click on finish, a project will be created and it will prompt for the SharePoint Online Credentials to connect with SharePoint Online.

Online Credentials


3.     Enter the credentials and click on Sign in button, we will find the project will be created with 2 solutions one is App and another one is APPWeb. See the below screen shot.
Solution view

   App Project will contain only app manifest XML which will be useful for configuration the app like default page and version of the app.


Right Click on App web project and click on Publish it will open the window to select the publish target. 
Publish Web

3.     I want to publish to the APPWeb in windows Azure, so we need to create a site in windows azure account. I have created with the site name as Bhanu test.

Azure site

3.     We need to download the publish profile in windows azure to publish the appweb to Windows azure. For this click on the site BhanuTest (site name) where I want to publish. Once click on the site you will navigate to the below page.

Azure Site Creation

Click on the Download the Publish Profile which is in the Publish your app section. Once click on the link a file will be downloaded.


Now go to the VS in Publish Target window click on Import it will prompt the window, where we can browse the profile which we have downloaded from Windows Azure site.

Publishing Web

Click on Ok. It will navigate you to the connection tab.

Publish web-1

Click on Validate Connection it will validated the connection, Once validation completes you will get the green symbol beside the validate connection button.


Publish Web1

Click on Next It will navigate you to the Settings tab where we can select the configuration. I am selecting the debug in the dropdown. 

Debug Mode

Click On next and Click on Start Preview it will show the files and click on publish.


Preview Selection

After Publishing it will navigate to the success page like below screen shot.


Site Creation
 
Now go to VS solution explorer you will find out the Publish Profiles folder which will contains the profile which we have downloaded from the Azure Site.

Solution Property

Now go to the Developer site and browse the appregnew.aspx page which will be available in the page layouts.


In this page we can create client id and client secret id. These id we can use in our APPweb and APP solutions. Client Id is bridge between the two solutions.


So browse the page and fill the information and click on create button.

App Reg page
Generate the Client Id, Client Secret Id. Give the Title for the app whatever you want.


App Domain and Redirect URI we need to give the windows azure site name. Redirect URI will allow only the https. Once fill the information click on create button app identifier will be created and you will be navigated to the below page.


App Identifier
 Now go to the Web.config file which is in the APPweb solution. Update the Client Id and Client secret id and publish the solution.

App Manifest

   Right Click on the APP solution and click on publish you will navigate to the      below page.

App Publishing
 
 Click on Deploy your web Project. It will prompt a window like below.

App Publishing -1

App Package

 Click on Publish. After that you need to package the app to upload the app in to site for click on the Package the APP which will be available in the publish your app page.


When you click on the Package the app, it will prompt the window like below.

Packaging App

 We need to enter the Client Id and update the site URL. Normally it will show    the URL without https so we need to update with https and click on Finish.
Now it will open the window which will contain the app file.  Now browse your SharePoint Developer site and upload this app in to apps testing.

Apps in testing

  Click On new app to deploy, It will open the below window.

Upload app selection

    Click on Upload hyperlink, once click on that it will open another window where    we can browse your app file.


Upload app selection-1


  Click on browse button and browse your app project, navigate to binà Debug     Ã  app.publish à go to version folder à select the app file and click on Ok.



Deploy App

It will show the above window which will be stated as your app has been     successfully uploaded. It’s time to deploy your App. Click on Deploy button. It will open the below wind and click on trust it.

Trusting App

Click on trust it button app will be installed. Now you can browse the app by accessing the site contents. 


No comments:

Post a Comment