dealing with and learning from the sandbox

40
Dealing with and Learning from the Sandbox Elaine van Bergen OBS

Upload: elaine-van-bergen

Post on 29-Nov-2014

872 views

Category:

Technology


0 download

DESCRIPTION

Presen

TRANSCRIPT

Page 1: Dealing with and learning from the sandbox

Dealing with and Learning from the Sandbox

Elaine van BergenOBS

Page 2: Dealing with and learning from the sandbox

Who Am I ?

• SharePoint 2010 MCM• SharePoint MVP• Co-organiser of Melbourne SharePoint User Group

(MSPUG)• @laneyvb on Twitter

Page 3: Dealing with and learning from the sandbox
Page 4: Dealing with and learning from the sandbox
Page 5: Dealing with and learning from the sandbox

Types

• SharePoint online dedicated• On-premise sandbox• SharePoint online

Page 6: Dealing with and learning from the sandbox

Online Dedicated

• Unlikely to be used by Australian or New Zealand Customers

• May actually be hosted not dedicated• Great case study for what Microsoft requires for

customisation• Plenty of advice useful for all SharePoint developers

Page 7: Dealing with and learning from the sandbox

Design Process for Customisation

• Gather requirements.• Create high-level design (HLD) document.• Microsoft review of HLD.• Develop custom solution.• Test, package, and validate with MSOCAF.

Page 8: Dealing with and learning from the sandbox

Design Guidelines - Examples

• Use native SharePoint functionality when possible• Evaluate the use of a client-side solution• Create logical solution versioning• Move business logic to separate classes• Develop asynchronous code that connects to an

Internet address• Ensure that dependencies to external systems are

managed correctly

Page 9: Dealing with and learning from the sandbox

Design Guidelines – Directory Structure

• Solution Artifacts • Release • Source code• Installation scripts• Test documentation

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18128

Page 10: Dealing with and learning from the sandbox

MSOCAF

• Guidance Package • Analyze Code

– Structure– FXCOP– Additional Rules

• Submit

https://caf.sharepoint.microsoftonline.com/Default.aspx

Page 11: Dealing with and learning from the sandbox

MSOCAF – Additional Rules

• SPList.Items • SPListItemCollection\GetItemByID inside loop• SPListItem.Update() inside loop• Log Exceptions in Feature Receiver and Report Back

to SharePoint• SharePointMonitorScope Webpart Check

https://caf.sharepoint.microsoftonline.com/Default.aspx

Page 12: Dealing with and learning from the sandbox

DemoMSOCAF

Page 13: Dealing with and learning from the sandbox

SharePoint Online Dedicated

Great Guidance for ANY SharePoint Development

Page 14: Dealing with and learning from the sandbox

On Premise Sandbox

• How does it work ?• Why ?• Development Setup

Page 15: Dealing with and learning from the sandbox

Sandbox Worker Process(SPUCWorkerProcess.exe)

User Code Service (SPUCHostService.exe)Execution Manager

(Inside Application Pool)

IIS(WPW3.EXE)

FRONT END

Sandbox Worker Proxy Process(SPUCWorkerProcessProxy.exe)

Full SP Object Model

SP Object Model Subset

Untrusted Code

Web.config / CAS Policies

BACK END

Page 16: Dealing with and learning from the sandbox

Deployment

• Solution Gallery at Site Collection• Site Collection Admin uploads and activates solution• Solutions are validated against policies• No artefacts on file system• No IIS Reset

Page 17: Dealing with and learning from the sandbox

Custom Validators

[GuidAttribute("34805697-1FC4-4b66-AF09-AB48AC0F9D97")]public class PublisherValidator : SPSolutionValidator{

[Persisted] List<string> _allowedPublishers;

public override void ValidateSolution( SPSolutionValidationProperties properties){ }

public override void ValidateAssembly( SPSolutionValidationProperties properties, SPSolutionFile assembly){ }}

Page 18: Dealing with and learning from the sandbox

Supported Artefacts

Page 19: Dealing with and learning from the sandbox

API Scope

• Sandboxed .Net Code– Very limited subset of Microsoft.SharePoint– Scoped to current SPSite and below– No SPSecurity– No web service , external data or other network

calls

• Client side code– Silverlight – JavaScript

Page 20: Dealing with and learning from the sandbox

Client.svc

Server OM

Contentdatabase

ECMAScript OM

Proxy

Managed OM

Proxy

Managed Controls and Logic

ECMAScriptControlsand Logic

XML Request

XML Request

JSON Response

JSON Response

Browser

Managed Client

SharePoint Server

Page 21: Dealing with and learning from the sandbox

Server (Microsoft.SharePoint)

.NET Managed(Microsoft.SharePoint.Client)

Silverlight(Microsoft.SharePoint.Client.Silverlight)

ECMAScript(SP.js)

SPContext ClientContext ClientContext ClientContext

SPSite Site Site Site

SPWeb Web Web Web

SPList List List List

SPListItem ListItem ListItem ListItem

SPField Field Field Field

Page 22: Dealing with and learning from the sandbox

Full Trust Proxy

• Operations in class that inherits Microsoft.SharePoint.Usercode.SPProxyOperation

• Arguments in serializable class that inherits Microsoft.SharePoint.Usercode.SPProxyOperationArgs

• Register full trust proxy• Recycle user code service• Consume via SPUtility.ExecuteRegisteredProxyOperation

Page 23: Dealing with and learning from the sandbox

Display Logic

Reusable/Complex Logic

Page 24: Dealing with and learning from the sandbox

Solution monitoring

• Protects Site Collection from resource intensive solutions

• Resource Points measure resource consumption• Site Collection Quota limits resource consumption

per day• Absolute Limit limits cuts of solutions when limit hit

Page 25: Dealing with and learning from the sandbox

Monitored Metrics

Metric Name Description Units Resources Per Point

Absolute Limit

AbnormalProcessTerminationCount Process gets abnormally terminated Count 1 1

CPUExecutionTime CPU exception time Seconds 3,600 60

CriticalExceptionCount Critical exception fired Number 10 3

PercentProcessorTime Note: # of cores not factored inPercentage Units of Overall Processor Consumed

85 100

ProcessThreadCount Number of Threads in Overall Process Threads 10,000 200

SharePointDatabaseQueryCount SharePoint DB Queries Invoked Number 20 100

SharePointDatabaseQueryTime Amount of time spent waiting for a query to be performed Seconds 120 60

UnhandledExceptionCount Unhanded Exceptions 50 3

Page 26: Dealing with and learning from the sandbox

Why ?

• Developers can deploy updates without IIS restarts• Site Collection Owners can control loading of

solutions• Complex code separated from display logic• Solution performance can be monitored and

controlled

Rapid changes possible with low Governance

Page 28: Dealing with and learning from the sandbox

Sandbox modes

• Local Mode:– Execute code on WFE– Low administration overhead– Lower scalability

• Remote Mode:– Execute on dedicated SharePoint servers– Load balanced distribution of code execution

requests

Page 29: Dealing with and learning from the sandbox

DemoSandbox Solutions

Page 30: Dealing with and learning from the sandbox

Common Pain Points

• Error Handling/Visibility• Configuration Storage• Limited API set• Learning curve required

Page 31: Dealing with and learning from the sandbox

On Premise Sandbox

Promotes efficient , well designed code that allows for rapid user interface change

Page 32: Dealing with and learning from the sandbox

SharePoint Online

• Development Process• Data Access• Authentication

Page 33: Dealing with and learning from the sandbox

Develop/ Debug

local.company.com

F5

dev.spo.contoso.com

*.wsp

*.wsp

spo.company.com/test

*.wsp

Upload/ Activate/ Deactivate

spo.company.com/prod

Page 34: Dealing with and learning from the sandbox
Page 35: Dealing with and learning from the sandbox

Data Access

• SharePoint data – Rest API, webservices, CSOM• JSON-P calling services

http://www.wictorwilen.se/Post/SharePoint-Online-and-External-Data-using-JSONP.aspx

• BCS + WCF Service + Client Object Model• Applications put or get data to/from SharePoint

Page 36: Dealing with and learning from the sandbox
Page 37: Dealing with and learning from the sandbox

Authentication

• Claims + Federation + Multiple Authentication Providers• FedAuth cookie with HTTP Only Flag = WinInet.dll • Active vs. Passive

COMPLICATED !

http://msdn.microsoft.com/en-us/library/hh147177.aspx http://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx

Page 38: Dealing with and learning from the sandbox

SharePoint Online Sandbox

Authentication and Data Access need to be carefully planned

Page 39: Dealing with and learning from the sandbox

Summary

Consider sandbox concepts as part of your solution design

@laneyvb

Page 40: Dealing with and learning from the sandbox

Bronze Sponsors Media SponsorsTechnology

Sponsor

Gold Sponsors

Silver Sponsors