Friday, August 3, 2012

Creating first SharePoint 2013 App

I was playing with SharePoint 2013 when preview was released and the first week gone through all UI, central administration features. After read the documentation, MSDN articles I was interesting to create my first SharePoint App.

Prerequisites:
  • We need Visual Studio 2012 to create your SharePoint 2013 App.
  • SharePoint Developer tools for Visual Studio 2012. If any else missing from installation install all from here like WIF SDK, Workflow Tools, Client Components etc..
  • Permissions to SharePoint site.
So, I have installed all of them and so enthusiastic to see my first app in SP2013. Created a new project in VS 2012 and selected my SharePoint 2013 site and SharePoint host App option. It's created below files as shown.

From project options [right click on solution or project, choose deploy] select deploy to deploy it to SharePoint site. It was not successful and end up with below errors in different trails. If you are getting anyone of the below errors please go through the related solutions and then proceed further steps.
Before you start developing App, the first thing we should do is, set up the environment for SharePoint Apps. This include below steps.
  1. Start SharePoint Administration Service and SharePoint timer Service. 
  2. Start App Manager Service and Subscription Settings Service.
  3. Create application pool for both services
  4. Associates the application pools to the services.
  5. Create database for each service to save the service specific information.
  6. Set appDomain for running apps.
  7. Set the app site subscription name [which comes as prefix in the app web url.]
Open the command prompt and execute the commands one by one to follow all the above 7 steps.
#Step 1
net start spadminv4
net start sptimerv4
#Step 2
Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance
#Step 3
$account = Get-SPManagedAccount "domain\farm account"
$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
$appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account
#Step 4 and 5
$appSubSvc = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPoolSubSvc –Name SettingsServiceApp –DatabaseName SettingsServiceDB
$appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName AppServiceDB
$proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc
#Step 6
Set-SPAppDomain appdomain
#Step 7
Set-SPAppSiteSubscriptionName -Name "app" -Confirm:$false
Note: The appDomain should be your application domain. Full qualified domain is preferable. And please make sure you are replacing the string "domain\farm account" with your actual farm account user.

If all the commands ran successfully without any issues then you are ready to create and deploy your first app to the SharePoint environment. Let me know if there are any issues.

No comments:

Post a Comment