Wednesday, July 15, 2015

Setup a development environment for Apps in SharePoint 2013

As Apps require a DNS entry, it is difficult to create a DNS entry for development environment. Below is the post which will guide you to setup a development environment for apps without DNS entry(using hosts file).

1. Add entry in hosts file.

Add a below entry in hosts file (C:\Windows\Systems32\drivers\etc)

127.0.0.1    apps.servername.com

where servername.com is Full Computer Name(which we can get by using Computer Properties)
















2. Modify Registry entry

Open the registry editor by typing regedit in the command prompt.
Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Add a new DWORD with Key  DisableLoopbackCheck
Edit and set its value to 1 (Decimal)
Re-Start your machine

3. Start the service

Run the below command in SharePoint powershell to start Admin, Timer , Apps and Subscription service

 net start spadminv4  
 net start sptimerv4  
 Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance  


4. Create a app management and substription service application

 $account = Get-SPManagedAccount "domain\user"   
 $appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account  
 $appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account  
 $appSubSvc = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolSubSvc -Name SettingsServiceApp -DatabaseName SettingsServiceDB   
 $proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $appSubSvc  
 $appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName AppServiceDB  
 $proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc  

where domain\user is the managed account name

5. Setup app domain 

Go to central administration site. On left navigation click "Apps".
Click on Configure App URLs in App Management.
Setup the app domain














You can also use below command to setup using powershell.

 Set-SPAppDomain "app.servername.com"  
 Set-SPAppSiteSubscriptionName -Name "app" -Confirm:$false  

6. Create an App

Open visual studio and create a new project, give a name as HelloWorldApp

















Provide the name of app.
Provide the development site SharePoint url
Select SharePoint-hosted as a hosts

















Click Finish.

Run the solution by clicking F5. The solution will run and you can see the app.




No comments:

Post a Comment