Dealing with and learning from the sandbox
Upcoming SlideShare
Loading in...5
×
 

Dealing with and learning from the sandbox

on

  • 792 views

Session delivered at the Australian SharePoint conference

Session delivered at the Australian SharePoint conference

Statistics

Views

Total Views
792
Slideshare-icon Views on SlideShare
789
Embed Views
3

Actions

Likes
0
Downloads
8
Comments
0

1 Embed 3

https://twitter.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • This must be the opening slide
  • Comprehensive list of best practises
  • SPMonitoredScope should be enabled for all custom methods of Web Parts except OnInit, Render, and OnPreRender.

Dealing with and learning from the sandbox Dealing with and learning from the sandbox Presentation Transcript

  • Dealing with and Learning from the Sandbox Elaine van Bergen OBS
  • Who Am I ?• SharePoint 2010 MCM• SharePoint MVP• Co-organiser of Melbourne SharePoint User Group (MSPUG)• @laneyvb on Twitter
  • Types• SharePoint online dedicated• On-premise sandbox• SharePoint online
  • Online Dedicated• Unlikely to be used by Australian Customers• May actually be hosted not dedicated• Great case study for what Microsoft requires for customisation• Plenty of advice useful for all SharePoint developers
  • 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.
  • 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
  • Design Guidelines – Directory Structure• Solution Artifacts• Release• Source code• Installation scripts• Test documentationhttp://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18128
  • MSOCAF• Guidance Package• Analyze Code – Structure – FXCOP – Additional Rules• Submithttps://caf.sharepoint.microsoftonline.com/Default.aspx
  • MSOCAF – Additional Rules• SPList.Items• SPListItemCollectionGetItemByID inside loop• SPListItem.Update() inside loop• Log Exceptions in Feature Receiver and Report Back to SharePoint• SharePointMonitorScope Webpart Checkhttps://caf.sharepoint.microsoftonline.com/Default.aspx
  • DemoMSOCAF
  • SharePoint Online Dedicated Great Guidance for ANY SharePoint Development
  • On Premise Sandbox• How does it work ?• Why ?• Development Setup
  • FRONT END BACK END User Code Service (SPUCHostService.exe)Execution Manager(Inside Application Pool) Sandbox Worker Process (SPUCWorkerProcess.exe) IIS (WPW3.EXE) Web.config / CAS Policies Sandbox Worker Proxy Process (SPUCWorkerProcessProxy.exe)
  • 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
  • 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){ }}
  • Supported Artefacts
  • 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
  • ECMAScriptControlsand LogicBrowser JSON Response ECMAScript OM Server XML Request OM Proxy Client.svc XML Request Proxy JSON Response Content Managed OM databaseManaged Client Managed Controls and Logic SharePoint Server
  • Server .NET Managed Silverlight ECMAScript(Microsoft.Shar (Microsoft.Shar (Microsoft.Shar (SP.js)ePoint) ePoint.Client) ePoint.Client.Sil verlight)SPContext ClientContext ClientContext ClientContextSPSite Site Site SiteSPWeb Web Web WebSPList List List ListSPListItem ListItem ListItem ListItemSPField Field Field Field
  • 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
  • Display LogicReusable/Complex Logic
  • 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
  • Monitored Metrics Resources Per AbsoluteMetric Name Description Units Point Limit Process gets abnormallyAbnormalProcessTerminationCount Count 1 1 terminatedCPUExecutionTime CPU exception time Seconds 3,600 60CriticalExceptionCount Critical exception fired Number 10 3 Percentage Units ofPercentProcessorTime Note: # of cores not factored in Overall Processor 85 100 Consumed Number of ThreadsProcessThreadCount Threads 10,000 200 in Overall ProcessSharePointDatabaseQueryCount SharePoint DB Queries Invoked Number 20 100 Amount of time spent waitingSharePointDatabaseQueryTime Seconds 120 60 for a query to be performedUnhandledExceptionCount Unhanded Exceptions 50 3
  • 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
  • Development Setup• Enable Microsoft SharePoint Foundation Sandboxed Code Service via CA• Download power tools http://visualstudiogallery.msdn.microsoft.com/8e602a8c- 6714-4549-9e95-f3700344b0d9• Download Silverlight toolkit http://www.microsoft.com/web/gallery/install.aspx?appid=sil verlight4tools;silverlight4toolkit;riaservicestoolkit
  • 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
  • DemoSandbox Solutions
  • Common Pain Points• Error Handling/Visibility• Configuration Storage• Limited API set• Learning curve required
  • On Premise Sandbox Promotes efficient , well designed code that allows for rapid user interface change
  • SharePoint Online• Development Process• Data Access• Authentication
  • spo.company.com/test spo.company.com/prod *.wsp Upload/ Activate/ Deactivatelocal.company.com
  • 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
  • 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.aspxhttp://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx
  • SharePoint Online Sandbox Authentication and Data Access need to be carefully planned
  • SummaryConsider sandbox concepts as part of yoursolution design @laneyvb
  • Gold Sponsors Silver SponsorsBronze Sponsors Media Sponsors