Friday, March 17, 2017

Configuration an environment for apps for SharePoint 2013

There are a lot of articles in internet about it (like this on msdn:  https://technet.microsoft.com/en-us/en-en/library/fp161236.aspx), but in my one I will share my own experience of full cycle which begins with configuration of servers and ends with deploying first app.

1. Configuration of DNS server.

We have two virtual servers in our development environment:  
  •          Domain controller (DC), Domain name - dev.com
  •          SharePoint 2013 server (SP2013)
On DC server in DNS Manager I added

a)       New Host(A or AAAA) on dev.com with the same IP address:


b)       New Alias (CNAME) on dev.com like this:


2. I configured SharePoint 2013 farm by Power Shell script below:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$appDomain = "apps.sp2013.dev.com" #your domain
$appPrefix = "app"
$accountName = "dev\spfarm" #login for pools
$accountPassword = "*********" #password

net start spadminv4
net start sptimerv4
Write-Host "Start" -foregroundcolor "green";
$existedAppDomain = Get-SPAppDomain
$existedAppPrefix = Get-SPAppSiteSubscriptionName


if (!$existedAppDomain -or !$existedAppPrefix)
{
        if (!$existedAppDomain)
        {
           Set-SPAppDomain $appDomain -ea:Stop
        }

        Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance
        Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"}
        $User = $accountName
        $account = Get-SPManagedAccount  -Identity $User -ea:Silently
        if(!$account)
        {
           $PWord = ConvertTo-SecureString –String $accountPassword –AsPlainText -Force
           $Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord
           $account = New-SPManagedAccount -Credential $Credential -ea:Stop
        }
       
        $appPoolSubSvc = Get-SPServiceApplicationPool -Identity SettingsServiceAppPool
        if (!$appPoolSubSvc)
        {
           $appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
        }
        $appPoolAppSvc = Get-SPServiceApplicationPool -Identity AppServiceAppPool
        if (!$appPoolAppSvc)
        {
           $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

        Set-SPAppSiteSubscriptionName -Name $appPrefix -Confirm:$false -ea:Stop
             Write-Host "End" -foregroundcolor "green";
}Write-Host "Registration Completed" -foregroundcolor "green";

3. Next, I created a simple SharePoint 2013 add-n app «Hellow word» and deployed it on my dev site collection.
But then I opened my deployed app I was prompted login and password multiple times with a blank page at the end. I modified my registry the way of this article described.   
I tried open my app again, entered login and passport and 'voila' the app was opened! But it was very strange:

4.  To fix it I created an empty root site collection on dev Web Application, that was all! 

5.  I also added the portal to intranet zone in IE:

No comments:

Post a Comment