Monday, April 27, 2015

Developing a SharePoint Hosted App

In this post we are going to talk about how can we Develop a SharePoint hosted Apps. This is divided in two primary steps.
  1. Develop the SharePoint Hosted App
  2. Discover the Deployed SharePoint Hosted App
Step - 1 : Develop the SharePoint Hosted App

Open visual studio 2013 , click on new Project , Select Apps for SharePoint 2013 template under Visual C# >Office/SharePoint>Apps.



Enter the project name as "DemoSPHApp" and provide the location where the code will reside.Click ok.Then it would It will open the wizard to create the project. Select the site ( Based on Developer / Team site definition) where you want to deploy the app . Select Hosting option as SharePoint-hosted.

























Click Finish. You would see primarily four main folders.
  1. Content - Responsible for App Content
  2. Images - Repository  for App Images
  3. Pages - All the app pages that needs to be deployed are stored in this location
  4. Script - All the scripts that is required for this app to function
Press  F5 and try to deploy the solution.you might run into the below error if you are trying to execute with the system account.

"Error occurred in deployment step "Installed app for SharePoint": The System Account cannot perform this action".

The Golden thumb rule is that ,You cannot deploy the apps with system account.Create another account, Provide the required permission on the SharePoint site and open the SQL server management studio and assign the db_owner permissions to this account, which you will be using to deploy the app for following databases.
  1. SharePoint_Config
  2. SharePoint_Admin_ [GUID]
  3. ContentDB to which the app is host. 
  4. Appmanagement_ServiceDB (app management service application database).
  5. SubscriptionSettings_ServiceDB (Subscription Settings service application database). 
Now use that account to deploy the apps using visual studio. I get the below error.



So now we Open the appmanifest file and Increment the app version by one. Now the App version is incremented from version 1.0.0.0 to 2.0.0.0. We also have modified the page title text on the "default.aspx" under the pages folder from "Page Title" to "Welcome to my First SharePoint Hosted App". Try to deploy the solution using the Visual Studio, one more time. Voola we see the new App.  


  
Step - 2 : Discover the Deployed SharePoint Hosted App

Click on Site content or you should be able to discover the newly deployed app on the left navigation (launch)  bar of the host Web.




Note : you can even publish the App using Visual Studio, Register the App on the App Catalog and make it Discoverable.









Sunday, April 19, 2015

Configure the Apps on SharePoint 2013

In this post you will learn how to configure Apps for  SharePoint 2013 on-premises.

The new app model requires some additional configurations on your environment
to allow you to start a development process for the SharePoint apps.

Before even configuring the Apps for SharePoint 2013, lets understand
What is Apps ? Apps are fundamentally a self-contained pieces of functionality that extends
the capability of a SharePoint Site.

There are three basic steps to configure App.
  1.  Configure an Isolated domain on the Domain Server for App
  2.  Create App Management and Subscription Setting service Application
  3.  Configure SharePoint to use App domain

Step - 1  : Configure an Isolated domain on the Domain Server for App

The first step is to create an isolated domain where your apps for SharePoint will run. This domain
should be a URL namespace that you reserve as a namespace for organizing apps. You have the option
to create a new unique domain such as yourappsdomain.com or create a sub-domain of the existing
domain such as apps.yourdomain.com.

Typical App URL Format  -  http[s]://[app prefix ]–[app id].[app domain]/[site collection path]/[app path]

 e.g  -  https://Apps-1234567ABCDEF.yourappsdomain.com/sites/sitename/webname/appname/default.aspx

Create a new forward look up zone




































   


































Create a wildcard alias record ( CNAME ) for the DNS domain name that allows for individual apps to create unique domain names within your app domain. Right click on the App domain and clickon the New Alias( CNAME ).

In the "Fully qualified domain name (FQDN)" for target host box, insert the domain name of the
target that hosts the SharePoint sites.



























Create a wildcard certificate SSL Certificate for the newly created App domain.Since this is a development environment, I am just using a self-signed certificate. 

Step - 2  : Create App Management and Subscription Setting service Application

For Apps make sure the following services are running in your farm

      -  App Management Service
      -  Microsoft SharePoint Foundation Subscription Settings Service 














 










Once the services is up and running , we can now create the App and Subscription service application. 
Again open the Power Shell Console,  Run as  "Administrator" , and execute the below script.











 Once the script is been executed, the App Management and the Subscription Setting service application is
 up and ready.

















The App Management service is responsible for storing App instance metadata, tracking App specific
configuration data that deals with App permission, App Security principals and App licensing.

The Subscription Setting service is responsible for managing tenancy.

Step - 3 : Configure SharePoint to use App domain

Navigate  to the Apps section in Central admin. Click on the Apps.











 






Once you get to the Apps page, click on the Configure App URLs.















 Provide the App Domain and the app prefix and click ok. Once we have configured the App URL. We will
need to create an App catalog site collection to hold our Apps. Select Manage App Catalog. Leave the
Create a new app catalog site choice selected and hit OK to advance to the Create App Catalog  page.






















That's all the minimum set of configurations required to develop apps on SharePoint 2013.Office 365 does
have all these configuration out of the box ,so there is no overhead to configure the apps on Office 365.

Note :: The Apps also do require to have the User Profile and the Managed Metadata service application up
and running.


Saturday, April 18, 2015

Why SharePoint APP Model

SharePoint App  is one  of the new features that is been introduced with SharePoint 2013. When Developing any new functionality on SharePoint 2013 you have three options.

  1. Fully Trusted Solution
  2. Sand box Solution
  3. SharePoint App Model

Solution Challenges

  1. Most of the fully trusted custom solutions runs within the SharePoint host environment.
  2. Managed code deployed using Sandbox solution runs within the SharePoint sandbox worker process.

Around 90% of cases, the primary cause for the instability of the SharePoint Farm is these Custom Solutions that runs within the SharePoint hosting environment.

Logically it makes more sense to move these custom solutions out of SharePoint hosting environment and convert these solution the App Model way, wherever possible. This would  minimizing the risk  and improving the stability of the SharePoint Farm.

The other advantage with the loosely coupled  App solutions would be that it would easily to upgrade an on-premises farm to a newer version.

SharePoint App is a standalone solution that are loosely integrated with SharePoint. The App Model is based on these main fundamental Design goals.

           -    App Code never runs within the SharePoint Host environment
           -    Apps must be supported in on-premises farm and in Office 365
           -    App permissions can be easily configurable independent to user permission
           -    Apps that are published in a app catalog , are easier to discover, install and upgrade