A Perspective on SharePoint 2013's App Model - Part 2
In part 1 of this series, I discussed why the way developers extend SharePoint needed to change. In this article I will detail types of SharePoint applications, how they fit into the app model, and the tools you can use to build applications.
What is a SharePoint App?
The words "SharePoint application" could probably mean a lot of different things to different people. Therefore, I want to do some level-setting before I dive specifically into the new App model. SharePoint provides a lot of functionality out of the box (search, workflow, lists, libraries, forms, content and document management, etc). The idea of building an application is really applying this functionality to a specific business need. I have seen some very effective "apps" that are nothing but out-of-the-box SharePoint functionality. So I thought I would talk about categories of applications first and then dive into the app model which usually enters the conversation when out-of-the-box functionality only gets you part of the way there. In my experience, you can categorize applying SharePoint to business processes along two different axis. These are the complexity of the desired user interface along with the complexity of the data model or business logic.
Side Note: Why would you ever need your own relational database? Let's be honest here. The SharePoint content databases are things of marvel. Almost whatever you want it to store a list of any type or tons of content it is really good at it. However, a yellow-flag for any solution is where a developer is using many SharePoint lists with lots of lookups and relationships. Or the developer has a list where they are expecting tons of items. Though SharePoint can store the content in both of these scenarios, should it? The main issues I have seen with applications is that SharePoint's content databases are a block-box. They are hands-off from a supportability point of view. So if you expect to write many reports against an extremely large list, odds are you will find yourself battling performance problems since you can't go into the database and add your own custom indexes. Plus it is important to realize that these lists don't give you much support in terms of transaction boundaries. If you app needs a sort of tracking database - odds are that it is better to host that outside of the content database.
Types of Apps in SharePoint 2013's App Model
- SharePoint Hosted: A "SharePoint hosted" application is a SharePoint app that contains no server side components. It can deploy everything it needs (libraries, workflows, content, etc) all within the SharePoint environment.
- Provider Hosted: A "Provider hosted" application is a SharePoint app that has server side components. For these components (usually contained within an ASP.NET application), you must provide a separate environment to host them. If could be a separate, non-SharePoint IIS server. Or it could be a virtual machine running in Azure's Infrastructure as a Service. As I stated in the earlier article, the server side components can really be developed in any technology as long as you can abide by the OAUTH requirements and make REST calls. But since Microsoft has done so much to make these remote components easy to build in ASP.NET, we will assume that going forward.
- Auto-Hosted: An "Auto-hosted" application is unique to Office 365 and the SharePoint Online service that runs there. If you are deploying on-premises you can cross this one of your list. However, if you are running in Office 365, it is one of the more ideal solutions. An auto-hosted application has server side components, but when you deploy the application to SharePoint, the service automatically spins up the server-side elements in an embedded Azure layer. It isn't Azure like you would manage in IaaS. It is more like the traditional Platform as a Service model where your app is deployed for you in a hosting environment you don't even log into. The biggest benefit of this model is that most of the registration and OAUTH plumbing is completely handed for you.
A little bit more vocabulary.... When you add a SharePoint app to a SharePoint site, it is important to understand where things are going. First, we refer to the SharePoint site you added the app to as the "host web". If the application has things it would like SharePoint to host (such as lists, libraries, content, etc), these components are put in a sub-site of the host web called the "app web". Usually this app web is accessed through a different top-level DNS entry then the SharePoint site to protect against cross-site scripting attacks. Having everything in the app web makes an uninstall very easy. When you remove the application, it removes the app web. Keep this in mind if you expect your data to be persisted despite the removal of your application from the site. You may need to place that content somewhere else like the host web. Lastly, if your application has server side elements, these are hosted outside the SharePoint infrastructure. We refer to that as the remote web.
What Kind of Tools Make SharePoint 2013 Style Apps?
I am going to go out on a limb here and not just make the statement that you need Visual Studio 2012. Almost everything on MSDN jumps immediately to this point. However, there are lot of tools that can get you into the SharePoint app world most with less development chops then Visual Studio would require. In fact, some of them are sort of built into SharePoint 2013 automatically. Here is a list:
- Access 2013: Yes Microsoft Access. It turns out that a wonderful feature of Microsoft Access is that you can create "web databases". If you are familiar with Access Services in SharePoint 2010, read carefully - a lot has changed. If you design an application with Access 2013 and you choose to start with a custom web database, the application will publish as a SharePoint app. The form interfaces become HTML 5 forms and the data gets housed in a custom SQL database outside of SharePoint's content databases. If you are running in Office 365, this means SQL Azure. On-premises you can designate on what SQL instance these databases should be housed.
- Napa: The Napa tool is a web based development environment for application that are SharePoint hosted and running in Office 365.
- Visual Studio Lightswitch: This tool was just recently released with Visual Studio 2012 Update 2. Lightswitch has always emphasized code generation where you customize screen templates and either build your own data model or connect to existing ones. This latest release has an option to deploy as a SharePoint application. The user interface is HTML 5 which is hosted in a remote web or auto-hosted. And the custom data model is housed by SQL Azure or SQL Server on-premises. Lightswitch even supports you referencing SharePoint lists in your data model.
- Visual Studio 2012: The developers tool.
In the next posts, I plan to go over some examples of applications and a bit more detail on OAUTH. Be on the look out.