developing a provider hosted sharepoint app

27
DEVELOPING A PROVIDER HOSTED SHAREPOINT APP Talbott Crowell Boston Area SharePoint User Group March 13 nd , 2013

Upload: talbott-crowell

Post on 03-Dec-2014

5.537 views

Category:

Technology


1 download

DESCRIPTION

Presented at BASPUG (Boston Area SharePoint User Group) on March 13, 2013.

TRANSCRIPT

Page 1: Developing a Provider Hosted SharePoint app

DEVELOPING A PROVIDER HOSTED SHAREPOINT APPTalbott Crowell

Boston Area SharePoint User Group

March 13nd, 2013

Page 2: Developing a Provider Hosted SharePoint app

About Me• http://about.me/talbott • Solutions Architect at ThirdM• A Founder of SharePoint Saturday Boston• Microsoft MVP• Blogger and Author• @talbott

Page 3: Developing a Provider Hosted SharePoint app

About this Talk• For Developers

• Who want to build Apps For SharePoint

• For Architects• Who want to understand options and architecture considerations of

a Provider Hosted App

• For Anyone • Who wants to learn more about SharePoint 2013 and the future of

Extending and Customizing SharePoint

Page 4: Developing a Provider Hosted SharePoint app

What is a Provider Hosted App• SharePoint 2013 Compatible Application• Hosted outside of SharePoint

• Azure• Amazon Web Services (AWS)• Rackspace• Your Datacenter• An on-premise server in your customer’s Datacenter (you provide

the Application, Hardware, and/or VM)

• Written in any language on any platform• Java, F#, Ruby, Linux, Unix

Page 5: Developing a Provider Hosted SharePoint app

App Development History• SharePoint 2003 – Web Parts• SharePoint 2007 – Farm Solutions & SPD

• WSP (A CAB file with deployment assets and instructions) which may include:• Server Code (.NET Assemblies for GAC or BIN)• Client Code (JavaScript Files, CSS, HTML)• ASP.NET (ASPX, ASCX, Master Pages), Images,

Site templates, List definitions, Content Types (CAML), Layouts, various other types of content

• SPD (SharePoint Designer)• Create custom solutions with Workflows,

JavaScript, HTML, jQuery, Master Pages, Layouts stored in Content Database

• SharePoint 2010• Sandbox Solutions

• SharePoint 2013• Apps for SharePoint

Page 6: Developing a Provider Hosted SharePoint app

Apps for SharePoint Hosting Options• Provider Hosted Apps

• SharePoint 2013 on-premise or Office 365

• Unlimited scaling

• Autohosted Apps• Typically Azure Web Sites written in

.NET• Runs only in Office 365 (no on-

premise option)• Uses the consumers Office 365

Azure resources

• SharePoint Hosted Apps• Client side only (JavaScript,

jQuery, HTML, CSS)• Uses CSOM to manipulate

SharePoint object

• http://bit.ly/spapphosting

Page 7: Developing a Provider Hosted SharePoint app

Provider Hosted Apps

SharePoint 2013

Provider Hosted

app

Provider Service

Office 365 Data Centeror On-Premise SharePoint 2013 Farm

Application Runtime and Backend(Can be anywhere: On-Premise or Cloud)

Customer Provider

Provider Data

Page 8: Developing a Provider Hosted SharePoint app

Alternative Using Autohosted

Office 365(SharePoint

Online)

Autohosted app

Windows Azure

Azure Database

Provider Service

Office 365 Data Center (including Azure)

Application Runtime and Backend(Cloud Service you Host)

Customer Provider

Provider DataCustomer Data

Page 9: Developing a Provider Hosted SharePoint app

Provider Hosted Architecture• Store or App Catalog – Deployment Manifest .APP file• App Manifest – Declare App Permission Requests• Trust Settings – User must “allow” or “trust” your app• Provider receives Request with Trust Token• Provider uses CSOM to call back to SharePoint using the

Trust Token• SharePoint persists changes made by the Provider in the

Content Database (just like SharePoint Designer)

Page 10: Developing a Provider Hosted SharePoint app

Costs of Being a Provider• Need to maintain and cover hosting cost

• But you can extend your app to other ecosystems outside of SharePoint• iPad, Facebook, Kindle, Salesforce

• Changes will affect ALL customers• May need a versioning strategy for customers in Life Sciences

(long validation lifecycle)

Page 11: Developing a Provider Hosted SharePoint app

Benefits of Provider Hosted• Does not tax the SharePoint Farm’s resources as much

as Farm Solution might• Update 1000’s of SharePoint Farms with one release

update to the Provider• Centrally managed at the Provider’s location• Develop on any platform using any language leveraging

your existing developer and infrastructure knowledge• Same App works on Office 365 and SharePoint 2013 on-

premise

Page 12: Developing a Provider Hosted SharePoint app

Development Model• Get Started using Azure and Office 365 Preview

• Many Blog posts on getting started

• Deploy your Provider Hosted app to your Provider (Azure, AWS, Rackspace, local server)

• Deploy your .APP file to SharePoint

Page 13: Developing a Provider Hosted SharePoint app

Development System Requirements• Visual Studio 2012

• On Premise Development Environment• http://bit.ly/spappdevenv

• Office Developer Tools for Visual Studio 2012• http://bit.ly/spapptools

Page 14: Developing a Provider Hosted SharePoint app

Decisions

• Office 365 or On-Premise?• If Office 365, Visual Studio 2012• If On-Premise then build your SharePoint 2013 Dev

Server• Windows Server 2012 or Windows Server 2008 R2 SP1• http://msdn.microsoft.com/en-us/library/fp161179.aspx • http://msdn.microsoft.com/en-us/library/fp179923.aspx

• Andrew Connell’s Critical Path Training • SharePoint 2013 Setup Guide for Developers

• http://bit.ly/cp2013setup

Page 15: Developing a Provider Hosted SharePoint app

App Packaging• Start with Visual Studio 2012 Project Template• .APP

• Contains AppManifest.xml• Set Permission Requests for your App• Start Page• Client ID

• App Icon Image File

• You can unpack the .APP by renaming .ZIP

Page 16: Developing a Provider Hosted SharePoint app

Demo• Using Visual Studio to create the App Manifest• Explore Contents

Page 17: Developing a Provider Hosted SharePoint app

Security• Client Secret vs Certificate

• Client Secret requires SharePoint is farm connected to ACS• Azure ACS (Access Control Service)• Office 365 is already connected to ACS

• AppManifest.xml (.APP)• Contains permissions

• OAuth• TokenHelper.cs (runs on the Provider)

• Helps you manage requests for app tokens• If you are developing in another language you will need to implement

this yourself

Page 18: Developing a Provider Hosted SharePoint app

OAuth ExampleTokenHelper.TrustAllCertificates(); string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);if (contextTokenString != null) { contextToken = TokenHelper.ReadAndValidateContextToken( contextTokenString, Request.Url.Authority); sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]); accessToken = TokenHelper.GetAccessToken( contextToken, sharepointUrl.Authority).AccessToken; CSOM.CommandArgument = accessToken; }

Page 19: Developing a Provider Hosted SharePoint app

CSOM• Client Side Object Model• Rich improvements over 2012• .NET version• JavaScript version• http://bit.ly/csom2013

Page 20: Developing a Provider Hosted SharePoint app

CSOM Exampleprotected void CSOM_Click(object sender,

EventArgs e) { string commandAccessToken = ((LinkButton)sender).CommandArgument; RetrieveWithCSOM(commandAccessToken); WebTitleLabel.Text = siteName; CurrentUserLabel.Text = currentUser; UserList.DataSource = listOfUsers; UserList.DataBind(); ListList.DataSource = listOfLists; ListList.DataBind(); }

http://bit.ly/spappbasic

Page 21: Developing a Provider Hosted SharePoint app

CSOM Example ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken( sharepointUrl.ToString(), accessToken);

//Load the properties for the web object. Web web = clientContext.Web; clientContext.Load(web); clientContext.ExecuteQuery();

//Get the site name. siteName = web.Title;

//Get the current user. clientContext.Load(web.CurrentUser); clientContext.ExecuteQuery(); currentUser = clientContext.Web.CurrentUser.LoginName;

//Load the lists from the Web object. ListCollection lists = web.Lists; clientContext.Load<ListCollection>(lists); clientContext.ExecuteQuery();

Page 22: Developing a Provider Hosted SharePoint app

Scope of Access• What can you get to from CSOM?

Page 23: Developing a Provider Hosted SharePoint app

Putting it all together• Generate Client ID and Client Secret

• Generated by form on SharePoint Online• https://<your site>/_layouts/15/appregnew.aspx

• APP Manifest and Icon packaged in .APP file• Includes Permission Requests• Includes Client ID• Deployed to SharePoint

• Your app is deployed to Azure, etc…• ClientID and ClientSecret

• Your app receives Token from SharePoint user request• Your app uses Token to call CSOM

Page 24: Developing a Provider Hosted SharePoint app

Review• SharePoint has completely new Development Model• Leverage existing understanding with CSOM• Leverage existing other technology knowledge• Update many customers (or Farms) at once• Costs and Benefits of being a Provider• Security with OAuth• Package and Deploy to Store

Page 25: Developing a Provider Hosted SharePoint app

Resources• My Blog for Slides, Questions, and Follow up information

• http://bit.ly/tcrowell

• Pluralsight Videos by Andrew Connell• Over 12 hours of Video• http://bit.ly/acplural

• Microsoft MSDN Documentation• http://bit.ly/spappmsdn

• CloudShare for developer and test hosting• http://www.cloudshare.com/

Page 26: Developing a Provider Hosted SharePoint app

More Resources• Steve Fox’s Blog

• Create a free Azure Web Site to develop Provider Hosted App• http://bit.ly/sfoxpart1• http://bit.ly/sfoxpart2

• Chris Johnson's loosely typed thoughts…• Build a SharePoint Provider Hosted App in 5 mins• http://bit.ly/spapp5min

Page 27: Developing a Provider Hosted SharePoint app

Thank You

Developing a Provider Hosted SharePoint AppPresented by Talbott Crowell

@talbott

Questions?