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!!