Wouldn’t it be awesome if you could deploy server side code to your office 365 tenant? Yes, it would! And with Windows Azure Auto-Hosted apps in SharePoint 2013 it is possible! This is amazing! I feel a little bit sorry for all the competitors. With the possibility to run server side code within Office 365 there are only few reasons to run SharePoint on premise. Especially midsize companies should consider really well to migrate to Office 365.
To get this working internally each Office 365 gets automatically an Azure account associated. More details about the architecture and billing will follow until the RTM.
In an azure auto-hosted app you can include:
- Web Projects (Shared IIS Hosting)
- SQL Azure Databases
- Create a Windows Azure Auto-Hosted App in Visual Studio 2013
- Deploy to SharePoint
- Add the App to a site
- SharePoint automatically provisions the Azure Website and the SQL Azure DBs that are included in the app package on the associated Azure tenant.
- User clicks app “A”, SP loads app specific page “B”
- Content Area “B” loads Windows Azure page
- Azure executes Code
- Azure can interact with SharePoint using Client Object Model (CSOM) and OData Services.
- Azure app can utilize SQL Azure DBs
- Azure app can interact with external services “C”
- Azure app can interact with the host site.
Let’s give it a try…
Create a SharePoint 2013 App in Visual Studio 2012 (don’t forget to start Visual Studio as an admin).
Enter the name of the app, the URL of your development site and choose “Autohosted”. For this app you do not need a local SharePoint Installation! I’ve used a developer site within the SharePoint Online 2013 preview.
Visual Studio will generates two projects. “SPAutohostedApp” constains the AppManifest for your remote app and SPAutohostedAppWeb is an ASP.NET Forms that projects that hosts your ASP.NET code. The included class “TokenHelper.cs” will do all the OAuth 2.0 magic for you.
The AppManifest.xml the defines the startpage of your remote app. “~remoteAppUrl” will be replaced with the url of your dynamically hosted web application. In the AppPrerequsites is defined that your web application should be automatically provisioned to azure .
Default.aspx includes sample code how to handle OAuth 2.0 authentication with the help of “TokenHelper” and how to callback to SharePoint using CSOM.
Trust the app.
Launch the app.
In debug mode the app will not be auto provisioned to azure. Visual Studio starts IIS Express to host and debug your ASP.NET website locally. When you launch the app in SharePoint Online the app url refers to localhost and you can debug your code. This is really handy.
Deploy the App
Now we’re going to deploy the app instead of debugging.
Trust and launch the app.
Checkout the URL. The website has automatically be provisioned to Azure! Awesome!
Create An App Package
In order to publish the app to your company’s app catalog or to the public marketplace you can build an app package.