Dealing with and learning from the sandbox
-
Upload
elaine-van-bergen -
Category
Technology
-
view
589 -
download
4
description
Transcript of Dealing with and learning from the sandbox
![Page 1: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/1.jpg)
Dealing with and Learning from the Sandbox
Elaine van BergenOBS
![Page 2: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/2.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/3.jpg)
![Page 4: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/4.jpg)
![Page 5: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/5.jpg)
Types
• SharePoint online dedicated• On-premise sandbox• SharePoint online
![Page 6: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/6.jpg)
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
![Page 7: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/7.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/8.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/9.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/10.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/11.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/12.jpg)
DemoMSOCAF
![Page 13: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/13.jpg)
SharePoint Online Dedicated
Great Guidance for ANY SharePoint Development
![Page 14: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/14.jpg)
On Premise Sandbox
• How does it work ?• Why ?• Development Setup
![Page 15: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/15.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/16.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/17.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/18.jpg)
Supported Artefacts
![Page 19: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/19.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/20.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/21.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/22.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/23.jpg)
Display Logic
Reusable/Complex Logic
![Page 24: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/24.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/25.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/26.jpg)
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 27: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/27.jpg)
Development Setup
• Enable Microsoft SharePoint Foundation Sandboxed Code Service via CA
• Download power toolshttp://visualstudiogallery.msdn.microsoft.com/8e602a8c-6714-4549-9e95-f3700344b0d9
• Download Silverlight toolkithttp://www.microsoft.com/web/gallery/install.aspx?appid=silverlight4tools;silverlight4toolkit;riaservicestoolkit
![Page 28: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/28.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/29.jpg)
DemoSandbox Solutions
![Page 30: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/30.jpg)
Common Pain Points
• Error Handling/Visibility• Configuration Storage• Limited API set• Learning curve required
![Page 31: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/31.jpg)
On Premise Sandbox
Promotes efficient , well designed code that allows for rapid user interface change
![Page 32: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/32.jpg)
SharePoint Online
• Development Process• Data Access• Authentication
![Page 33: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/33.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/34.jpg)
![Page 35: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/35.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/36.jpg)
![Page 37: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/37.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/38.jpg)
SharePoint Online Sandbox
Authentication and Data Access need to be carefully planned
![Page 39: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/39.jpg)
Summary
Consider sandbox concepts as part of your solution design
@laneyvb
![Page 40: Dealing with and learning from the sandbox](https://reader033.fdocuments.us/reader033/viewer/2022052904/557ad721d8b42a85648b4683/html5/thumbnails/40.jpg)
Gold Sponsors
Bronze Sponsors Media Sponsors
Silver Sponsors