Wednesday, March 27, 2013

Sharepoint 2013 – How to share contents between Apps

Usually, in the previous versions of SharePoint, if you had to deploy 2 or more web parts to one or more servers you had to deploy the shared content to a shared container like the _layouts directory for each server. The same goes for 2 or more SharePoint Applications.
Let me draw an example:
Image
Due to the new SharePoint 2013 model, if you have the same problem as before, you cannot deploy the contents in the _layouts directory if you want to release a 100% compliant Office 365 app.
So, for example, if I developed 4 apps in my DEV environment and I used a mixed solution like deploying a Farm WSP with all my shared contents in the _layouts directory these coming to be unusable on SharePoint online.
The best options to share your contents are to adopt one of the following two:
  • SharePoint Web Application
  • Azure
    • ASP.NET Web Application
    • Blob storage
      • CDN

So if you start to use one of those options you'll start to implement an architecture like this:
Image(1)


SharePoint Web Application
The idea behind is something that comes from the old versions of SharePoint. You could deploy a web application and have it in an assets library, anonymously accessible if you need, where the web parts or the apps can access to download them.
shared by webapp
This solution is restricted because the boundary is the SharePoint farm where the SharePoint Web Application lives.
If you have an app installed outside your farm (and it should be the usually), you have to configure your farm to give the access from outside. That makes it hard to maintain, and also unsafe for your LAN.


Azure

ASP.NET Web Application
I picked up this idea from Chris O'Brien. He uses this solution as his choice.
The easy idea is to use a public web project on azure. So you should have a web site published on Azure:
25-03-2013 16-37-37
and through VS 2012 you can deploy your assets:
vs2012_wwb_azura


Blob storage and CDN
Windows Azure Blob is a service for storing large amounts of unstructured data that can be accessed from anywhere in the world via HTTP or HTTPS.For more information about the blob storage you can read the following link: http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage-v17/
The
CDN is an option of the blob storage and that is a global solution for delivering high-bandwidth content by caching blobs and static content: http://www.windowsazure.com/en-us/develop/net/common-tasks/cdn/
To
upload the files on your blob storage you can develop your own client or you can use something that exists already, like this: http://azurestorageexplorer.codeplex.com/
You just have to create a blob container on your Azure, for this example I created the images container:
this is my blob service with the CDN option enabled:
azure blob storage


and this is my images container:
azure container
cool eh!? :)
Ok now that your Share Content Environment is ready you can refer to it with code.

Some considerations
Sharing contents between apps shouldn't be usual but could be if you have to develop more than one app for a client project (same logos, same css, shared javascript!).
IMHO these are the best solutions you could implement.
If you have some other ideas, please let me know ;)

No comments:

Post a Comment