How to set up a SharePoint 2013 app development environment (without DNS)

With SharePoint 2013 Microsoft integrated the app contept into the SharePoint world. This gives us new opportunities, but also sets new requirements. SharePoint apps got their own enviroment where they will be installed and run. With this step Microsoft made sure the SharePoint experience will not be affected negativ by bad running apps or apps that want to steal data. But this isolation requires, that apps got their new oen DNS entry. The app do not have the same URL as the SharePoint. An app URL looks like this: <prefix>-<GUID of the app (will be generated automatic)>.<appdomain> (example: http://app-005f804530bdb6.app.development/). To create and manage a new DNS entry is way to much work for a development enviroment and that is the reason why there is a way to do it without DNS.
To set up a development enviroment you will need some time and a user user with administrator permissions. In the first step you need to set up a SharePoint server. After this is completly done and the SharePoint works you need to connect to the server. On the server you need to add a line to the hosts-file (you can find it under C:\Windows\System32\drivers\etc). The line will be added to the bottom of the file and is build of the IP address for localhost (127.0.0.1) and the appdomain you want (in my example 'app.development'). So the line looks like this: 127.0.0.1 app.development. Now the necessary preparations are done, now we can open PowerShell (as administrator). Into the PowerShell you need to enter a lot of comands. You can find them in this MSDN article: Configure an isolated app domain to create and deploy SharePoint-hosted apps.

What the lines in this article do is to set up some srevices and make sure some other are running. At first it makes sure the spadmin and the sptimer services are running.

1
2
net start spadminv4
net start sptimerv4

After that the appdomain will be set (it is the domain you wrote into the hosts file).

1
Set-SPAppDomain "app.development"

Then it makes sure the SPSubscriptionSettingsService and the AppManagementServiceInstance are started.

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

Now an account will be set that startes the following steps. It needs to be the farm account.

1
$account = Get-SPManagedAccount "development-enviroment\SPFarmAdmin" 

In the next step it creates SPSubscriptionSettingsServiceApplication and SPAppManagementServiceApplication.

1
2
3
4
5
6
$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

The last step sets the prefix of the URL. It requires that all previous steps are finished succesfully. If this step does not work you need to repeat all previous steps and maybe you need to delete the created services.

1
Set-SPAppSiteSubscriptionName -Name "app" -Confirm:$false

In this case the prefix is 'app'. Now the syste, is ready and you can develop apps on the server.If you want to develop apps from your local machine you need to do one step more. You need to activate a hidden feature. For this step you will ne a PowerShell instance, which is started as administrator, too. In this line you call the feature by ID and the URL of the SharePoint.


1
Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url  http://developmentSharePoint/

Now you can connect with Visual Studio from your local machine to your SharePoint and develop apps.

App Catalog

The App Catalog is a SharePoint tool to manage apps and publish them to all Site Collections. The App Catalog will be created and managed in the Central Administration in the category 'Apps' → 'Manage App Catalog'.
To publish apps in the App Catalog you need to open your app in Visual Studio. Then make a right click on your project and click 'Publish...'.



A new window opens. Click the 'Package the app' button in the category 'Publish'. A folder will be opened. This folder contains a '*.app'-file. Drag and drop this file into the library 'Apps for SharePoint' in your App Catalog. Now every Site Collection of this SharePoint will list this app in the 'Add an app' menu. Selecting it there will install it for the Site Collection. Remember that each installation gots his own enviroment.

Comments

Popular posts from this blog

How to support multiple languages in WPF