App Development in SharePoint 2013 - 204.144.121.229204.144.121.229/Shared Documents/App Development...

Preview:

Citation preview

© 2013 McGladrey LLP. All Rights Reserved. © 2013 McGladrey LLP. All Rights Reserved.

Cincinnati SharePoint User Group – 04/24/2014

App Development in SharePoint 2013

© 2013 McGladrey LLP. All Rights Reserved.

About McGladrey Ranked fifth-largest assurance, tax, and business consulting provider in the U.S., for RSM McGladrey, Inc. and McGladrey & Pullen, LLP combined (Source: Accounting Today 2010 Top 100 Firms)

- Nearly 90 offices in the U.S. - 7,000 employees in the U.S.

Members of RSM International, one of largest global networks of independent accounting, tax, and consulting firms

- Presence in 76 countries - More than 32,000 people in 736

offices Provides global resources with a single point of contact Delivering outstanding client service for over 80 years McGladrey is the brand under which RSM McGladrey, Inc. and McGladrey & Pullen, LLP serve clients’ business needs. The two firms operate as separate legal entities in an alternative practice structure.

1

© 2013 McGladrey LLP. All Rights Reserved.

Technology Consulting Capabilities

2 2

Advise Deliver Maintain

Enterprise Risk Management

Consulting Strategy and Advisory

Strategy Development Assessments Due Diligence System Selection Business Continuity and

Disaster Recovery Benchmarking/Best

Practices Project and Program

Management

Support Business & Technology

Outsourcing Finance and Accounting

Outsourcing IT Outsourcing CIO Advisory Application Outsourcing Infrastructure Outsourcing Hosting/Private Cloud Managed Services

Applications Design and Implementation

Enterprise Resource Planning (ERP) Customer Relationship

Management (CRM) Business Analytics Corporate Performance

Management Systems Integration Knowledge Management,

Portals and Collaboration

Business Performance Improvement

Infrastructure Design and Implementation

Network Design and Implementation (LAN/WAN)

Carrier Assessment/TEM Server Virtualization Storage and Recovery Desktop/Application Delivery Unified Communications and

Mobile Computing

Cloud Solutions Software as a Service (SaaS), Platform as a Service (PaaS), Infrastructure as a Service (IaaS)

We offer a comprehensive scope of technology services, covering IT Strategy, Application and Systems Integration, Infrastructure and Outsourcing.

© 2013 McGladrey LLP. All Rights Reserved.

Introduction

Arun Aggarwal - Consulting Manager - SharePoint Practice - Great Lakes Region - Dayton, OH

arun.aggarwal@mcgladrey.com

© 2013 McGladrey LLP. All Rights Reserved.

Developing SharePoint apps

Introduction to SharePoint apps Developing SharePoint apps Distribution and deployment App lifecycle events

© 2013 McGladrey LLP. All Rights Reserved.

Pain points with SharePoint solutions

Custom code runs inside SharePoint environment

Custom code has dependencies on DLLs Permissions model based on entirely on user

identity - No permissions for the solution itself - Impersonation helps with too-little-permissions

problem - Impersonation causes too-many-permissions

problem SharePoint solutions are hard to manage

© 2013 McGladrey LLP. All Rights Reserved.

SharePoint 2013 Deployment Options

On-premises SharePoint Online

© 2013 McGladrey LLP. All Rights Reserved.

SharePoint app life cycle

© 2013 McGladrey LLP. All Rights Reserved.

A big picture SharePoint 2013

Workstation

Laptop

Smart Phone Tablet

SharePoint App (Hosted)

Remote Application (LAMP, ASP.NET, ASP.NET MVC, Java….)

SharePoint App (Hosted)

Custom Application 1 Custom Application 2

SharePoint Farm

Site Collection 2

Site Collection 1

List 1

List Item 2

MNovember 13

T W T F S S1 2 3

4 5 6 7 8 9 1011 12 13 14 15 16 1718 19 20 21 22 23 2425 26 27 28 29 30

Doc Lib

Kiosk (PHP.NET)

© 2013 McGladrey LLP. All Rights Reserved.

SharePoint app model overview

SharePoint app model based on the following assumptions - Apps supported in Office 365 and in on-premises farms - App code never runs in SharePoint host environment - Apps talk to SharePoint using Web service only - App code is authenticated and has established identity - App has permissions independent of user permissions - Apps deployed to catalogs using a publishing scheme - Published apps are easier to find, install and upgrade

© 2013 McGladrey LLP. All Rights Reserved.

Important Terms…

Hosting Model - SharePoint-hosted - Cloud-hosted

App Web Remote Web App Catalog App Store (SharePoint Store) App Domain Tenancy

© 2013 McGladrey LLP. All Rights Reserved.

App Development - On-premises

2 Service Applications required App Management Service Application (Central

Administration) Microsoft SharePoint Foundation Subscription

Settings Service Application (PowerShell script is the only way)

App Domain – PowerShell Script Tenant Name – PowerShell Script

© 2013 McGladrey LLP. All Rights Reserved.

Error resolution tips

Error resolution in the SharePoint 2013 app development environment - Disable the loopback check - No UI to create Microsoft SharePoint Foundation

Subscription Settings Service Application • PowerShell script available to jump start

© 2013 McGladrey LLP. All Rights Reserved.

PowerShell helper scripts

# ----------------------------------------------- # Load SharePoint PowerShell snapin Write-Host Write-Host "(2 of 6) Verify SharePoint PowerShell Snapin Loaded" -ForegroundColor White $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.PowerShell'} if ($snapin -eq $null) { Write-Host " .. loading SharePoint PowerShell Snapin..." -ForegroundColor Gray Add-PSSnapin "Microsoft.SharePoint.PowerShell" } Write-Host " Microsoft SharePoint PowerShell snapin loaded" -ForegroundColor Gray

# assign root domain name to configure URL used to access app webs Set-SPAppDomain "apps.devsharepoint11" –confirm:$false

$account = Get-SPManagedAccount “NATIONALDEV\spadmin” Remove-SPServiceApplicationPool -Identity "SettingsServiceAppPool" $appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account Remove-SPServiceApplicationPool -Identity "AppServiceAppPool" $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

# assign name to default tenant to configure URL used to access web apps Set-SPAppSiteSubscriptionName -Name "McGladreyTenant" -Confirm:$false

© 2013 McGladrey LLP. All Rights Reserved.

Disable the loopback check

Click Start, click Run, type regedit, and then click OK In Registry Editor, locate and then click the following

registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSe

t\Control\Lsa Right-click Lsa, point to New, and then click DWORD

Value Type DisableLoopbackCheck, and then press ENTER Right-click DisableLoopbackCheck, and then click

Modify In the Value data box, type 1, and then click OK Quit Registry Editor, and then restart your computer

© 2013 McGladrey LLP. All Rights Reserved.

App Url (Start Page)

http://mcgladreytenant-2cfd74a2325d8b.apps.devsharepoint11/SharePointAppRestDemo/Pages/Default.aspx

Tenant App

Domain App

Name App UID

© 2013 McGladrey LLP. All Rights Reserved.

Types of app

No Hosting Type of Code (Server / Client)

Technology (CSOM / REST)

Comments

1 SharePoint Hosted Server Code CSOM Not Allowed 2 SharePoint Hosted Server Code REST Not Allowed 3 SharePoint Hosted Client Code CSOM Possible 4 SharePoint Hosted Client Code REST Natural for JavaScript 5 Cloud Hosted Server Code CSOM Natural for C# 6 Cloud Hosted Server Code REST Possible 7 Cloud Hosted Client Code CSOM Possible (Not desirable) 8 Cloud Hosted Client Code REST Possible (Not desirable)

© 2013 McGladrey LLP. All Rights Reserved.

Client-side JavaScript with CSOM

$(document).ready(function () { SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () { sharePointReady(); }); });

© 2013 McGladrey LLP. All Rights Reserved.

Client-side JavaScript with REST

OData – Open Data protocol – Uses standard HTTP verbs to send and retrieve data in standardized formats such as Atom, JSON, plain XML

Requires parsing together these URLS according to the rules outlined by OData protocol

http://devsharepoint11/ _api/web/?$select=Title service root - http://devsharepoint11 resource path - _api/web query options - ?$select=Title

© 2013 McGladrey LLP. All Rights Reserved.

Server-side with CSOM

protected void Page_Load(object sender, EventArgs e) { // retrieve app web URL from incoming query string parameter string appWebUrl = Page.Request["SPAppWebUrl"]; using (ClientContext clientContext = new ClientContext(appWebUrl)) { Web appWeb = clientContext.Web; clientContext.Load(appWeb); clientContext.ExecuteQuery(); lblAppWebTitle.Text = appWeb.Title; }

© 2013 McGladrey LLP. All Rights Reserved.

Server-side with CSOM - 2

// code added to start page protected void Page_Load(object sender, EventArgs e) { // cache url to web app for other pages Cache["SPAppWebUrl"] = Page.Request["SPAppWebUrl"]; } generic handler named appWebTitle.ashx $("#appwebtitle").load("/Pages/appWebTitle.ashx");

© 2013 McGladrey LLP. All Rights Reserved.

Server-side with REST

// retrieve URL to app web string appWebUrl = Page.Request["SPAppWebUrl"]; // create URL for REST call to query for app web Title property Uri uri = new Uri(appWebUrl + "/_api/web/?$select=Title"); // transmit HTTP GET request to SharePoint host environment HttpWebRequest requestGet = (HttpWebRequest)WebRequest.Create(uri); requestGet.Credentials = CredentialCache.DefaultCredentials; requestGet.Method = "GET"; HttpWebResponse responseGet = (HttpWebResponse)requestGet.GetResponse(); // retrieve Title property from XML returned by SharePoint host environment XDocument doc = XDocument.Load(responseGet.GetResponseStream()); XNamespace ns_dataservices = "http://schemas.microsoft.com/ado/2007/08/dataservices"; lblAppWebTitle.Text = doc.Descendants(ns_dataservices + "Title").First().Value; HttpWebRequest GetResponse Method HttpWebRequest and HttpWebResponse and XDocument class converts XML document to create HTML list element

© 2013 McGladrey LLP. All Rights Reserved.

Server-side with REST 2

Form Digest In client side the value of form digest is available on the page. Not in server side. There is a get call required to get the value private string GetFormDigest(){ string appWebUrl = Cache["SPAppWebUrl"].ToString(); Uri uri = new Uri(appWebUrl + "/_api/contextinfo"); HttpWebRequest requestPost = (HttpWebRequest)WebRequest.Create(uri); requestPost.Credentials = CredentialCache.DefaultCredentials; requestPost.Method = "POST"; requestPost.ContentLength = 0; HttpWebResponse responsePost = (HttpWebResponse)requestPost.GetResponse(); XDocument doc = XDocument.Load(responsePost.GetResponseStream()); XNamespace ns_dataservices = "http://schemas.microsoft.com/ado/2007/08/dataservices"; return doc.Descendants(ns_dataservices + "FormDigestValue").First().Value; }

© 2013 McGladrey LLP. All Rights Reserved.

Demo

© 2013 McGladrey LLP. All Rights Reserved.

SharePoint tenancies

A tenancy is a set of site collections - Configured and administered as a unit - Created with administrative site collection - A scope for provisioning new site collection - Central concept to site management in Office 365 - A requirement for installing SharePoint apps

What about tenancies in on-premise farms? - Most farms do not have explicitly created tenancies - To add support for SharePoint apps, on-premise

farm can be configured with a farm-wide default tenancy

© 2013 McGladrey LLP. All Rights Reserved.

Service application support for apps

App support requires two service applications - App Management Service - Site Subscription Management Service - These two services must be created in on-

premises farms to support apps

© 2013 McGladrey LLP. All Rights Reserved.

App installation scopes

Site-Scoped Installation - App is installed in a specific site - App is launched from same site - This site is known as host web

Tenancy-Scoped Installation - App installed -> app catalog site - App available many host webs - Host webs access one app instance - Centralizes app management

© 2013 McGladrey LLP. All Rights Reserved.

SharePoint app architecture

SharePoint-hosted apps - App resources added to SharePoint host - Stored in child site knows as app web - App can have client-side code - App cannot have server-side code

Cloud-hosted apps - App resources deployed on remote server - Remote site known as remote web - App can have client-side code - App can have server-side code

© 2013 McGladrey LLP. All Rights Reserved.

App start page

Every app requires a start page - Start page provides entry point into app - SharePoint adds app launcher to Site Contents in

host web - SharePoint-hosted app start page hosted by

SharePoint - Cloud-hosted app start page hosted in remote web

© 2013 McGladrey LLP. All Rights Reserved.

App hosting models

SharePoint-hosted App - App deployed to app web created under child site

Provider-hosted App - App deployed to remote web on remote web server - Developer deploys remote web prior to app

installation Auto-hosted App

- App deployed to remote web in Office 365 environment

- Office 365 deploys remote web during app installation

© 2013 McGladrey LLP. All Rights Reserved.

App manifest

All apps require app manifest (AppManifest.xml) - SharePoint reads manifest metadata during app

install - Metadata used to configure installed app instances - Visual Studio 2012 provides app manifest designer

© 2013 McGladrey LLP. All Rights Reserved.

Start Page URL

Dynamic tokens used in start page URL - SharePoint-hosted apps use ~appWebUrl token ~appWebUrl/Pages/Default.aspx - Cloud-hosted apps use ~remoteAppUrl token

~remoteAppUrl/Pages/Default.aspx - All apps should use (StandardTokens) token

~appWebUrl/Pages/Default.aspx ~remoteAppUrl/Pages/Default.aspx

© 2013 McGladrey LLP. All Rights Reserved.

App Web

App Web is created during app installation - App Web created as child to site where app is

installed SharePoint-hosted apps must create app web

- App must add start page and related resources - App can add other SharePoint elements (i.e. lists)

Cloud-hosted apps can optionally create app web - Most cloud-hosted apps will not create an app web - Cloud-hosted app can create app web if needed

© 2013 McGladrey LLP. All Rights Reserved.

App Web hosting domain

App web pages served out of isolated domain - Isolates JavaScript code on app web pages - Allows SharePoint to authenticate callbacks from app

https://McGladreyTenant-ee060af276f95a.apps.McGladrey.com/HelloWorldApp

URL to app web made up of 4 parts - Tenancy name: McGladreyTenant - APPUID: ee060af276f95a - App web hosting domain: apps.McGladrey.com - App name: HelloWorldApp

© 2013 McGladrey LLP. All Rights Reserved.

Host web features

SharePoint apps can extend UI three ways - Start Page (required) - App Parts - UI custom actions

App Parts and UI custom actions added host web - Added to host web using a host web feature - Users add app parts just like adding web parts - UI custom actions used to extent ribbon and ECB

menu - The development details available later

© 2013 McGladrey LLP. All Rights Reserved.

App distribution overview

App Packaging - Packaging app resources for distribution

App Publication - Making app available for installation and upgrade

App Installation - Make app available for use

App Upgrade - Replace current version of app with newer version

© 2013 McGladrey LLP. All Rights Reserved.

App package

SharePoint apps distributed using app packages - App package is ZIP archive file with .app extension - Built according to Open Package Convention

(OPC) - Same packaging format used in Apps for Office - App package must contain Appmanifest.xml - App package will often contain file for app icon - MySharePointApp.app

• AppManifest.xml • AppIcon.png.config.xml • AppIcon.png

© 2013 McGladrey LLP. All Rights Reserved.

App Web Solution Package

App package contains inner WSP for app web - Elements deployed to app web using solution

package - Solution package built into app package as inner

WSP - All SharePoint-hosted apps will have an inner WSP

in their app package - Cloud-hosted apps will not have an inner WSP in

their app package unless the have been implemented to create an app web

© 2013 McGladrey LLP. All Rights Reserved.

Packaging host web features

Host web feature elements added at top level - Element.xml file added for each app part - Element.xml file added for each UI custom action - Feature.xml file added for host web feature - Visual Studio adds GUI to file names

© 2013 McGladrey LLP. All Rights Reserved.

Packaging for autohosted apps

Autohosted apps packaged with extra resources - Office 365 requires resources to deploy remote

web • Built into app package as web deploy package (web.zip)

- Office 365 requires resources to create SQL Azure DB • Built into app package as Data Tier Application Package

(dacpac)

© 2013 McGladrey LLP. All Rights Reserved.

Publishing apps

App distributed based on publishing scheme - Publishing involved uploading app package to catalog - Provides better app discovery, installation and upgrade

Office Store is catalog available to general public - Developers publish apps to Office Store - Anyone can discover apps and purchase / install them

App catalog site for publishing at private scope - Implemented as a SharePoint site collection - Used in Office 365 tenancies and in on-premise farms - Must be explicitly created in on-premised farm

© 2013 McGladrey LLP. All Rights Reserved.

Creating an app catalog site

App catalog site created in Central Administration - App catalog site is created at web application

scope

© 2013 McGladrey LLP. All Rights Reserved.

“Apps for SharePoint” document library

App catalog site contains support for… - Publishing SharePoint apps - Publishing Apps for Office - Managing user request for apps

Apps for SharePoint is special document library - It is the place where you publish SharePoint apps - You upload app package and add related metadata

© 2013 McGladrey LLP. All Rights Reserved.

Installing apps

You must be administrator of site to install an app - Click “add an app” link on Site Contents page - This takes you to app discovery page - Click an app tile to install it - After installation, app tile added to Site Contents

page - App tile provides fly-out menu to assist with app

management

© 2013 McGladrey LLP. All Rights Reserved.

Installing apps at tenancy scope

App catalog site used for tenancy-scoped install - Step 1: Publish app to app catalog site - Step 2: Install app in same app catalog site - Step3: Configure app to make it available in other

sites.

© 2013 McGladrey LLP. All Rights Reserved.

Upgrading apps

Overview of SharePoint app upgrade process - App catalog tracks current version number of app - SharePoint host records app version at install time - Updated version of app can be uploaded to app catalog - SharePoint host notifies used when there’s new version

User makes choice whether upgrade or not - User is never forced to upgrade - If user decides to upgrade, it involved clicking a button - Provider-hosted apps must support multiple versions

© 2013 McGladrey LLP. All Rights Reserved.

App lifecycle events

SharePoint app models support app events - App events for installation, upgrade and uninstall - SharePoint host calls to entry point in remote web - Not support in SharePoint-hosted apps - Added to app project using property sheet

© 2013 McGladrey LLP. All Rights Reserved.

Programming App Events

App Events implemented using ProcessEvent method

© 2013 McGladrey LLP. All Rights Reserved.

Questions

Recommended