Introduction to SharePoint 2013 Apps

26
SharePoint Saturday Chicago Suburbs A Developer’s Introduction to SharePoint 2013 Apps Ryan McIntyre, MCITP, MCPD National Architect, Neudesic @ryanmcintyre

description

As developer’s, we’ve been used to creating and deploying custom solutions directly on our SharePoint 2007 and 2010 farms using farm solutions. By now, you’ve heard that SharePoint 2013 creates a new model for developing customizations and the push is for us to adopt this new model to create our solutions and have them execute separate from the farm. This is quite a big shift! While there are many benefits to moving towards a services based architecture for our solutions, this new model impacts not only how we deploy and manage our customizations but also the tools that we use to create them. How does the app model impact my designs? What tools and languages should we use? How do I now deploy my custom solutions? In this session, we’ll answer these questions and more. We will look at the new app model architecture and learn how they work in a SharePoint 2013 environment, review some capabilities that are added and some that are removed, and cover the deployment options and decision criteria to use when designing your apps. The session will wrap up with a discussion on coding techniques we can implement to make our solutions more maintainable and able to leverage the new app model and you will leave with some clear take-away items you can use to get started developing apps for SharePoint 2013!

Transcript of Introduction to SharePoint 2013 Apps

Page 1: Introduction to SharePoint 2013 Apps

SharePoint Saturday Chicago Suburbs

A Developer’s Introduction to

SharePoint 2013 AppsRyan McIntyre, MCITP, MCPDNational Architect, Neudesic

@ryanmcintyre

Page 2: Introduction to SharePoint 2013 Apps

2 SharePoint Saturday Chicago Suburbs

Speaker Feedback: SPSCSM.COM

Page 3: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Agenda Why Apps App Model App Hosting Models Development Strategies

Page 4: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Introducing SharePoint App Model SharePoint applications no longer live in SharePoint

Custom code executes in the client, cloud or on-prem

Apps are granted permissions to SharePoint via OAuth

Apps communicate with SharePoint via REST / CSOM

Acquire apps via centralized Marketplace Corporate Marketplace Public Marketplace (via submission process) APIs for manual deployment

Page 5: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

App PrinciplesApps are a very different philosophical change to extending SharePoint More scenario-focused

Event Tracking Ticket Management System

Robust Built-in robust semantics for install, upgrade & uninstall

Apps are for End Users Cloud & Web-Oriented

Page 6: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

User Experience Everything in a SharePoint site is an app

Contact form Travel request Shared Documents library Contacts list

Formerly known as View All Content, the Site Contents link shows all apps in a site & links to the SharePoint Store (public) and App Catalog (internal)

Selecting an app redirects to the app’s start page

Page 7: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

SharePoint Solutions & AppsFull-Trust Solutions

Sandboxed Solutions

Apps

Use Client-Side SharePoint API

Use Server-Side SharePoint API

Use Remote Services

App-based Permissions (OAuth2)

On-Premise Deployment Friendly

Hosted Deployment Friendly

Distribution via Marketplace

SharePoint Provided Schematics for Install / Upgrade / Uninstall

Page 8: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Choices when Building Apps

App D

esi

gn

Choic

es

Hosting

Entry Points / Experience

Scoping

Page 9: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Hosting: Choice of Three Architecture Approaches

App Web

(from WSP)

Parent Web

SharePoint-Hosted App

Provision an isolated sub web on a parent web• Reuse web elements

(lists, files, out-of-box web parts)• No server code allowed; use

client JavaScript for logic, UX

Provider-Hosted App

“Bring your own server hosting infrastructure”

SharePoint

WebGet remote events from SharePoint Use CSOM/REST + OAuth to work with SP

Cloud-based Apps

Your Hosted Site

Autohosted App

Windows Azure + SQL Azure provisioned invisibly as apps are installed

Windows Azure

Websites

SharePoint Web

Page 10: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Hosting: Cloud vs. SharePoint

Cloud Hosted Apps SharePoint Hosted Apps

Preferred hosting model for almost all types of apps

Good for smaller apps & resource storage

Full power of web – choose your infrastructure & technology

SharePoint-based; no server-side code

May require your own hosting Automatically hosted in SharePoint

May require you own handling of multitenancy & permission management

Inherent multitenancy & isolation

Page 11: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

App User Experience Decisions

UX

Deci

sions

App Shape Entry Point & App

Shape

Branding Custom / SharePoint

UI

Page 12: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Entry Point / Experience: App Shapes

Shape Description Example

Immersive Full Page App

App that implements a new scenario for customers

Resource Tracking, Budgeting

App Part Provides new parts you can add to your sites

Weather, Team Mascot, News

Extension App Add new actions for documents and items

Display Document Visualization, Print to Print Service Vendor

Page 13: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

App Branding User Experience Guide for SharePoint 2013 Apps

Options App Template

ASPX page hosted in SharePoint app.masterpage: includes AppWeb chrome Default option when creating apps with VS

Chrome Control Custom Branding

Must include “Back to Site” link in upper-left

App Chrome Options

App Templa

te

Chrome Control

Custom Chrome

Page 14: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

App Scoping

Web ScopeCan register and use resources in parent site,

site collection

Tenant ScopeCan register start page, custom actionsTenant Admins can filter-enable on sites

By Site Collection, Managed Path, Template Type

(SharePoint-hosted tenant-scope apps not available)

Page 15: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

Application Isolation When apps are provisioned, new SPWeb (AppWeb) created within hosting SPWeb Each app resides within it’s own SPWeb for isolation Special DNS address configured by administrators App SPWeb’s live in separate domain (DNS)

Each App hosted on it’s own unique URL because: Blocks XSS: isolation to special SPWeb under special domain blocks

cross site scripting Enforces App Permissions: apps communicate with sites via CSOM /

API & must be granted to do so

Page 16: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

App Model Type 1: SharePoint Hosted SharePoint hosted apps wholly reside in SharePoint

Uses SharePoint artifacts (lists/libraries) Business logic executes or on the client

HTML5 JavaScript

Page 17: Introduction to SharePoint 2013 Apps

@ryanmcintyre

#SPSChiBurbs

App Model Type 2: Cloud Hosted Cloud hosted apps primarily execute outside of SharePoint

May use SharePoint artifacts (lists/libraries) Communicate via CSOM / REST Granted permission to SharePoint via OAuth

Business logic lives & executes outside of SharePoint On-Premise hosted web application Windows Azure 3rd party host

Page 18: Introduction to SharePoint 2013 Apps

New Context

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

using (var clientContext = spContext.CreateUserClientContextForSPHost()){ clientContext.Load(clientContext.Web, web => web.Title); clientContext.ExecuteQuery(); Response.Write(clientContext.Web.Title);}

Page 19: Introduction to SharePoint 2013 Apps

Separation of Concerns

Page 20: Introduction to SharePoint 2013 Apps

Typical SharePoint 2010 codeprotected override void CreateChildControls(){ //Create the list selector listOfSiteLists = new DropDownList(); ListItem newItem; //Get the current SPWeb and find all the lists using (SPWeb currentWeb = SPContext.Current.Web) { foreach (SPList currentList in currentWeb.Lists) { //Add each SharePoint list to the drop-down list newItem = new ListItem(); newItem.Text = currentList.Title; newItem.Value = currentList.ID.ToString(); listOfSiteLists.Items.Add(newItem); } } this.Controls.Add(listOfSiteLists);}

Page 21: Introduction to SharePoint 2013 Apps

What if we did this…protected override void CreateChildControls(){ //Create the list selector listOfSiteLists = new DropDownList(); ListItem newItem;

ISPContent MySPContent = Injector.Get(“SPContent”); List<ISPList> mySPListList = MySPContent.GetListsForCurrentWeb();

foreach (ISPList list in mySPListList) { //Add each SharePoint list to the drop-down list newItem = new ListItem(); newItem.Text = list.Title; newItem.Value = list.ID; listOfSiteLists.Items.Add(newItem); }

this.Controls.Add(listOfSiteLists);}

interface ISPList{ string Title { get; } string ID { get; } void Add (string title, string id);}

public List<ISPList> GetListsForCurrentWeb(){ List<ISPList> mySPListList = GetSPListInstance(); using (SPWeb currentWeb = SPContext.Current.Web) { foreach (SPList currentList in currentWeb.Lists) { mySPListList.Add(currentList.Title, currentList.ID.ToString()); } } return mySPListList;}

Page 22: Introduction to SharePoint 2013 Apps

Then we could do this…protected override void CreateChildControls(){ //Create the list selector listOfSiteLists = new DropDownList(); ListItem newItem;

ISPContent MySPContent = Injector.Get(“SPContent”); List<ISPList> mySPListList = MySPContent.GetListsForCurrentWeb();

foreach (ISPList list in mySPListList) { //Add each SharePoint list to the drop-down list newItem = new ListItem(); newItem.Text = list.Title; newItem.Value = list.ID; listOfSiteLists.Items.Add(newItem); }

this.Controls.Add(listOfSiteLists);}

public List<ISPList> GetListsForCurrentWeb(){ List<ISPList> mySPListList = GetSPListInstance();

#region GetContext Token and hostWeb

using (var context = TokenHelper.GetClientContextWithContextToken (hostWeb, contextToken, Request.Url.Authority))

Web web = context.Web;

IEnumerable<SP.List> result = context.LoadQuery(web.Lists.Include( list => list.Title, list => list.Id)); context.ExecuteQuery();

foreach (List list in web.Lists) { mySPListList.Add(list.Title, list.Id); } return mySPListList;}

Page 23: Introduction to SharePoint 2013 Apps

Loosely Coupled Code

Page 25: Introduction to SharePoint 2013 Apps

SharePoint Saturday Chicago Suburbs

Ryan McIntyre, MCITP, MCPDhttp://blog.randomdust.com

[email protected]@ryanmcintyre

Page 26: Introduction to SharePoint 2013 Apps

26 SharePoint Saturday Chicago Suburbs

Speaker Feedback: SPSCSM.COM