sharepoint hosted app new vrsn - winwire technologies … · with that short introduction on...

12
Technologies How to Setup On-Prem SharePoint Hosted App WinWire Technologies Inc. 2350 Mission College Boulevard, Suite 925, Santa Clara, California, 95054 Email : [email protected] On-Prem SharePoint Hosted App Pg.1 Copyright© 2016 WinWire Technologies

Upload: vuongxuyen

Post on 08-Jul-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Technologies

How to Setup On-Prem SharePoint Hosted App

WinWire Technologies Inc.2350 Mission College Boulevard,

Suite 925, Santa Clara, California, 95054Email : [email protected]

On-Prem SharePoint Hosted App

Pg.1 Copyright© 2016 WinWire Technologies

Page 2: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.2 Copyright© 2016 WinWire Technologies

Step By Step On-Prem SharePoint Hosted App & ConfigurationWith that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing one, on our On-Prem environment. I assume that you have an admin access to the dev machine that has all the necessary software installed, for example, SharePoint 2013, Visual Studio etc.

Step 1: Creating a Subscription Settings Service Application and ProxyWe need a Subscription settings service application to configure App URL’s in Share-Point. In order to create this service application, we first need database access:

1. Make sure that your login has dbcreator role on the master db.2. db_owner access on the App Management Service application’s db. In case, App Management service application is missing, create a new one (Check the TechNet article)

On-Prem SharePoint Hosted App

Page 3: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.3 Copyright© 2016 WinWire Technologies

Subsequently, , open SharePoint 2013 management shell as an admin and run the following commands:

$account = Get-SPManagedAccount "<AccountName>" # Where AccountName is any managed account

$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Ac-count $account

Get a managed account:

Create an app pool for Subscription services

$appSubSvc = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolSubSvc -Name SettingsServiceApp -DatabaseName <SettingsServiceDB>

# Where <SettingsServiceDB> is the name of database you want to giveOnce the service application is created head over to Central Administration and check:

1. CA->Application Management -> Manage Service application. Ensure that you start the Subscription Settings service application and proxy that you have created .

2. CA->System Settings -> Manage services on server. Ensure that the just App Management and subscription settings services are started.

SharePoint app runs in a separate app domain of its own, in order to deploy and work with apps, we first need to provision app domain in on premise environment. As mentioned before in office 365 environment these are already configured for us. So let’s create one.

Create the service application

Step 2: Creating an App Domain

On-Prem SharePoint Hosted App

Page 4: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.4 Copyright© 2016 WinWire Technologies

1. On the SharePoint server open Administrative tools -> DNS or search for DNS. a. If you fail to find DNS, that means it has not been installed. Open Server Manager- Dashboard and install DNS by clicking on Add Server Roles and Features. Check this article 2. Open DNS, expand the server node. Right click on Forward Lookup Zones and chose New Zone.

3. Click on Next. Let the default be selected as Primary Zone, click on next and give a name to your app domain

On-Prem SharePoint Hosted App

Page 5: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.5 Copyright© 2016 WinWire Technologies

4. Click on Next, then Next, another Next and Finish.

5. Once the new Zone is created, right click on it and choose New Alias ( CName)

6. This part is bit confusing.

a. Enter * for Alias name. b. *. MyApps for FQDN c. The fully qualified domain name for target host should be the full system name. Copy it from Name Server (NS ) node or through computer properties

On-Prem SharePoint Hosted App

Page 6: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.6 Copyright© 2016 WinWire Technologies

Note# Ensure the Name Server (NS) is mapped to a correct IP address. Double click then click resolve if not. Once done open command prompt and do a quick ping test to your new domain as ping test.myapps.com, a response means the domain is created correctly.

After we have created the subscription services & an app domain, we are now ready to configure the App URL in Sharepoint. Before completing these 2 steps, if you try to configure App URLs, it will throw an error suggesting subscription service needs to be configured, that’s why we completed those steps earlier. Now we are ready to configure our App URLs.

1. Go to CA->Apps->Configure APP URLs2. AppDomain = Name of the New Zone we created above3. App Prefix -> Any prefix you want to use. As you can see on the screen the pat tern an app URL uses <app prefix>-<app id>.<app domain>4. Click on Ok

Step 3: Configuring App URL’s

These steps do not directly affect your app creation/hosting but would make the development process much easier. SharePoint prompts for user name password every time you run the app, these steps will ensure it automatically logs you in.

Step 4: Disabling loopback check and automatic login

On-Prem SharePoint Hosted App

Page 7: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.7 Copyright© 2016 WinWire Technologies

a) Click on Start -> Run and type regeditb) Locate the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsac) Right click on this key and choose New > DWord Valued) Name this one "DisableLoopbackCheck"e) Double-click then on it and type the value “1”f) Reboot your server. (Mostly not required)

Finally, what we have been waiting for. Let’s create our first demo app since all pre-requisites have been completed.

Next, go to "Internet Options\Security\Internet\Custom Level\User Authentication\Logon" enable "Automatic logon with current user name and pass-word"

a) Open Visual Studio as an administrator. Point to New->Project and chose “App for SharePoint” under Office/SharePoint -> Apps

Step 5: Creating a SharePoint Hosted App

On-Prem SharePoint Hosted App

Page 8: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.8 Copyright© 2016 WinWire Technologies

b) Give it a name and click on nextc) Give your developer site URL, chose “SharePoint-hosted” for How you want to host your app question

d) Click on Next, it should automatically pick SharePoint 2013 as the SharePoint version.

e) Click on Finish, your app is now created.

f) Visual studio will add a default page & necessary scripts to your app, so you can start writing your code. You can add/modify as needed. The code is fairly self- explanatory.

On-Prem SharePoint Hosted App

Page 9: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

Pg.9 Copyright© 2016 WinWire Technologies

On-Prem SharePoint Hosted App

g) For sake of demo, open app.js file and modify the lines as below. We are just replacing the default message on the start page with our own.

h) Right click your project and chose deploy, it will build and add the app to “Apps in Testing” library.

i) Go to your Dev site, Site Contents-> Apps in testing & verify if the app is deployed

Page 10: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

As mentioned at the start of the post, this article targets a development & not a production environment. Although app creation steps are same in your production environment your IT team will have created the necessary infrastructure, DNS server settings for you

Step 6: Adding host File entry

Pg.10 Copyright© 2016 WinWire Technologies

On-Prem SharePoint Hosted App

j) Click on the HelloWorld_SPHostedApp to run it. You will a get a page cannot be displayed error.

What went wrong?

Page 11: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

For apps to resolve the domain names, they depend on DNS servers which route requests to the appropriate servers. In the dev environment, however, we need to take care of that by adding entries to the host file on your dev machine.

By default, if you deploy the app from Visual Studio it adds the host entries, but if you get the page cannot be displayed error, we need to add them manually.

a. Open notepad as administrator (Right click, run as admin)

b. Browse to “C:\Windows\System32\drivers\etc” see all files & open hosts file

c. Add an entry for your app as below

If you recall or look at the browser, the app URL comprises off

Pg.11 Copyright© 2016 WinWire Technologies

On-Prem SharePoint Hosted App

Page 12: SharePoint Hosted App New Vrsn - WinWire Technologies … · With that short introduction on SharePoint hosted apps, let’s now get started with the actual configurations & developing

d. Browsers cache Host entries, so wait for a few mins or restart the web browser and run your app once again & VIOLA!

We have our app running!

Pg.12 Copyright© 2016 WinWire Technologies

On-Prem SharePoint Hosted App

Note: The host file entry must be modified every time the app is re-deployed as a new app id is generated each time. This could be a bit cumbersome, however this is the only option we have on a dev machine.

e. Once you are done, you can publish your app which will create the. app fie and upload it to the App Catalog for re-use. How to, is beyond scope of this article

Hope this article helps you get started on writing your own SP hosted apps in an on-prem environment.