Wednesday, July 18, 2012

Creating a SharePoint 2013 App - set the App Domain

Hello world...I finally have my first SharePoint 2013 App deployed!!  It was an interesting road.  The answer is to very carefully follow the steps in this document from MSDN, in particular, to set up your App domain.

Like many of you, I first installed SharePoint 2013, then Visual Studio 2012 RC, then ran the web install to get the SharePoint 2013 development extensions added in.  So far so good!  I then started up Visual Studio, saw the new "Apps" entry in the Office/SharePoint templates for Visual Studio, and created a new project based on the "App for SharePoint 2013" project type.  Cool!

But, when I deployed my App, SharePoint came back with the error "Failed to install App for SharePoint" in Visual Studio's Error list.  The Output window didn't show much more than that.  When I looked in the ULS log for my App's project name, I found this helpful message:

An App domain must be configured prior to completing this operation

That got me thinking there must be more involved in setting up an App, so when all else fails, I decided to read the doco.  I know, crazy!!  But before creating an App, you need to configure a hosting 'domain' for your Apps.  This is for on-prem hosting, I'm sure for Office 365 there's a similar process just so your HelloApp app won't overwrite my HelloApp app.

The PowerShell command "set-SPAppDomain" did the trick.  Since the document says to also link this domain to the Subscription Settings and App Management service apps, I deleted both of these apps thru Central Admin, then used the referenced script to create them.  This does need the farm account, which in my case was already registered as a Managed Account.

$account = Get-SPManagedAccount "mydomain\myfarmaccount"
$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
$appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account
$appSubSvc = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPoolSubSvc –Name SettingsServiceApp –DatabaseName O13Preview_SettingsServiceDB
$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $appSubSvc
$appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName O13Preview_AppServiceDB
$proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc

All that ran fine.

Interestingly, I had an error on this last step:

Set-SPAppSiteSubscriptionName -Name "mydomain" -Confirm:$false

Note that the name isn't the same name given in the set-spappdomain step - the above didn't like the period separator, so I used just the leftmost part of my domain.

The error, though, was another surprisingly clear error message.  PowerShell came back with an error from the SecureToken web service site (port 32843), checked to make sure the service was running, tried to delete the service app and recreate it but SharePoint wouldn't let me; looked in the logs again and there was the message:  " System.InsufficientMemoryException"

So that's clear enough!  My VM was running with 8GB of RAM - I had shut down some non-essential services like BCS, Word Automation, Visio, Access, etc., earlier, but looks like 8GB isn't enough.

After I increased RAM to 12GB I was able to do that last command, and finally I have a deployed app!!




5 comments:

Unknown said...

hey I am not able stuck at
$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $appSubSvc

I am getting following error message
New-SPSubscriptionSettingsServiceApplicationProxy : Missing an argument for
parameter 'ServiceApplication'. Specify a parameter of type
'Microsoft.SharePoint.PowerShell.SPServiceApplicationPipeBind' and try again.
At line:1 char:66
+ $proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy
-ServiceApplica ...
+
~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-SPSubscript...pplicati
onProxy], ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,Microsoft.SharePoint.PowerShell.
SPCmdletNewSubscriptionSettingsServiceApplicationProxy

LET me know in case you have any solution for this

Unknown said...

hey Steve,

I ran the $appSubSvc = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPoolSubSvc –Name SettingsServiceApp –DatabaseName O13Preview_SettingsServiceDB

with different SettingsServiceApp and DatabaseName it worked.

Unknown said...

However I did not face any issues running

Set-SPAppSiteSubscriptionName -Name "myapp" -Confirm:$false

Anonymous said...

Nice blog post! Really helped to understand some concepts. Here is my take on the same!
http://praveenbattula.blogspot.in/2012/09/install-app-for-sharepoint-failed-to.html

Unknown said...

Hi,
I`m getting a symilar error when I`ve tried to configure apps on my SP 2013 dev whe I`ve run:
$proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc
The error was:
New-SPAppManagementServiceApplicationProxy : Cannot bind argument to parameter because it is null.
The previous command was good. It create the db and didn`t give any error.
$appSubSvc = New-SPSubscriptionSettingsServiceApplication -
ApplicationPool $appPoolSubSvc -Name SettingsServiceApp2 -DatabaseName SettingsS
erviceApp2DB
Please advise.
Thanks