Monthly Archives: October 2012

Build a SharePoint Provider Hosted App in 5 mins

The Goal:  Build and deploy a really simple SharePoint App to SharePoint Online with the code running in an Azure Web Sites website.

Provider Hosted Apps are simply a SharePoint app where the code in your app runs in a space you provide.  That could be Azure, AWS or wherever you like. I’m picking Azure Web Sites because its free and awesome.

Before you begin:

  • Office 365 preview account (get one here for free)
  • Azure Web Sites account (get one here for free)
  • Visual Studio 2012 with the “Microsoft Office Developer Tools for Visual Studio 2012” add on installed (get it here for free)

Now on to the fun stuff….

Setting up an Azure Web Site:

1. Create a new Azure Web Sites site

image

2. When its created go into the dashboard for it and get the publishing profile for Visual Studio. Save it to your computer for later.

image

Setting up SharePoint Online:

1. Create a new Developer Site Collection in the SharePoint admin center.

image

2. Pick the Developer Site template when creating it

image

3. When your site has been created navigate to it.  Then hit the following URL to register a new App Id and Secret.  These are used for the OAuth between your App and SharePoint Online.

https://<my SPO site url>.sharepoint.com/sites/<your site collection>/_layouts/15/appregnew.aspx

4. Complete the form.

NOTES:

  • Use the Generate button to create the App Id and Secret.
  • Put your exact Azure Web Sites domain name in the App Domain box
  • Put the HTTPS address to your site + /Pages/Default.aspx in the Redirect URI

image

5. Click ok and you will get confirmation the App config has been created. Make a note of all these settings someplace safe.

image

Creating your SharePoint App

1. Create a new SharePoint App project in Visual Studio 2012.  If you don’t see this template then you don’t have the pre-reqs installed at the start of this post. Go and install the “Microsoft Office Developer Tools for Visual Studio 2012”

image

2. Enter the URL to your SharePoint Online development site collection and pick “Provider Hosted” from the dropdown.  Click validate beside the URL to ensure you have got it right.  It may prompt you to log into SharePoint online to do this.

SNAGHTMLfcf6d9

Visual Studio will create two projects in your solution:

  • SharePoint project <= this is where your app config goes
  • Web Site Project <= this is where your apps code and pages go

3. Right click the AppManifest.xml file and pick View Code to see the XML

4. Replace the “*” in the following line with your App Id you generated earlier

<RemoteWebApplication ClientId=”*” />

Should look something like this:

<RemoteWebApplication ClientId=”1B6B757E-1D3B-4375-8494-D885035A769B” />

5. Change the URL in the StartPage to the Fully Qualified Domain Name of your Azure site + the path to /pages/default.aspx?{StandardTokens} like this:

image

6. Open the Web.config file in your web project and set the ClientId and ClientSecret setting to the ones you generated previously.

image

7. Hit F6 to build the solution and make sure it compiles.

Deploying your App

1. Right click on the web project in the solution and Pick “Publish”

image

2. Click the Import button and pick the Profile file you downloaded from Azure previously. Go and download it from Azure if you were lazy and skipped this step earlier you naughty person.  Validate the connection to make sure its working by clicking the Validate button.

SNAGHTML1072599

3. Click Publish and let your site deploy.  When done a browser should pop up like this:

image

4. Go back into the Azure management dashboard and for you site click into the Configure tab. Create the ClientId and ClientSecret app settings.  Azure websites reads them from here … even if you have them in your web.config.  So not doing this will mean your app crashes.

image

Oh and remember to click the Save button at the bottom of the page when you are done (yes I failed at this a number of times)

image

5. In Visual Studio hit F5 to deploy your app to SharePoint Online. It will package and deploy your application.

6. You will see a browser pop open asking you if you Trust your app.  OF COURSE YOU DO! 🙂 Click Trust It.

image

7. You will see your new app listed in the site contents.  Click It!

image

8. Enjoy the obligatory “Working on It” screen

image

9. You will be redirected to your App and should see the Title of your site written to the page like this (or whatever you called your site when you created it):

SNAGHTML110fcb4

10.  BOOM! Congrats you created your first provider hosted app!

In the out of the box project templates in Visual Studio it creates a default page that uses the Client Side Object Model (CSOM) to call SharePoint Online and get the Title of your web site.  All the goo you set up with Ids and Secrets above is what is used by the CSOM to authenticate using OAuth with SharePoint online to ensure your code is allowed. The CSOM takes care of a lot of the heavy lifting for you so its all hidden away. 

When you click your app tile in SharePoint you might have seen it redirect you via the /_layouts/15/appredirect.aspx page.  This redirects you to your application via a POST along with some context about who the caller is, so that your code in Azure knows who you are & has the right tokens to call back into SharePoint as that person.

All the plumbing that makes this work is pretty detailed and way too much to cover in this post … but I suggest anyone interested read about App and OAuth in MSDN here: http://msdn.microsoft.com/en-us/library/fp142382(v=office.15).aspx

Drop a comment if you have any questions or issues!

Thanks,

-CJ

Surface with Windows RT

Just pre-ordered a new Surface and really looking forward to getting it in a imageweek or so.

I am really trying to stay open minded about this device.  As you may know I am an MS kool-aid drinker for WAY back … but I have spent plenty of time with other devices too.  I used to have an iPhone 3G, 3GS and a 4. I have an iPad (v1) currently that is my couch surfing device of choice.

A lot of people are asking my why get the RT version (ARM) over the Pro (x86) in 3 months time.

I want to replace my iPad.  I am not looking for a laptop replacement right now. That is why I don’t care about running existing Windows desktop apps etc…

On top of that here are a few things why I think I will like the Surface better than my iPad:

  • Physical keyboard built into the screen cover.  I’m only one flip away from productively typing a blog post like this vs. feeling like a nonce trying to type it on the crappy on screen keyboard.
  • USB – plug in full size keyboard, mouse, printer etc…
  • Expandable storage
  • Multi-Tasking apps, snapped view of twitter while doing something else.

But who really knows right?!?! The proof will really be in the pudding and my intention is to update this post with my thoughts and views after having used it for a while.

Also ill post my “Will it blend” or whatever other iPad disintegration video I come up with.

-CJ.

SharePoint 2013 RTMs … my thoughts

Yesterday Microsoft announced Office 2013 and SharePoint 2013 released to manufacturing (RTM). 

RTM is kind of a funny term these days as it is a hang up from the old days when everything was punched onto a CD/DVD and that is how the majority of software was shipped.  Today that is definitely not the method most people get their software.  Sure you can buy Office in a store and get a imageDVD … but by far the most common way people will get Office 2013 is when they buy a new computer, or upgrade by buying it from MS and downloading it.  SharePoint doesn’t come on a DVD anymore and the only way to get it is to download it (MSDN and TechNet aside).

Picture:  Office 2010 special commemorative shipping edition. A special edition keepsake for those who worked on 2010.  Nice boxed product memento.

Anyway … I digress 🙂

Yesterday was 10/11/12 in US date format.  I remember hearing that date for RTM over a year ago when I was working on the SharePoint team.  Its amazing to me that a date can be set like that, over a year out, and it be hit on time.  Amazing.  Especially when you understand the complexity of building and shipping software that is used by 100s of millions of people around the world.  Amazing. 

Personally I am really happy MS hit the date and congratulate everyone on making it!!!

Given my history with SharePoint I thought I would throw a few thoughts together about this release.  As some will know I was working on the team while the project was underway and feel a little bit vested in the success of the product … still.  It holds a special place in my heart.

Online
Probably the biggest most interesting thing for me in this release is how much more viable SharePoint Online will be in Office 365.  It was a great product already … but this new version will open it up to a LOT more companies and people.  It is so much closer in feature set to the on premises product that 365 is today.  A lot of companies are hesitant to move until they can do the same things online … and fair enough I say.  Bringing the two much closer together is a great first step.  E.g. Search.  FAST search isn’t in online today … but the new built from the ground up Search engine in 2013 will be.  That is just one example.

Developer stuff
I wont be popular for saying this with some people … but something had to change with SharePoint development.  By that I mean:

The Full Trust code model in SharePoint we have 2010 needs to die. 2013 takes the first step towards that.

As powerful as the server object model is it desperately needed reinventing.  Running code inside SharePoint processes is dangerous, insecure and costly to run for IT departments.  Moreover, next to impossible to run well in SharePoint Online. 

The new plumbing available to developers in 2013 is the first small step towards fixing that problem.  Sure, it’s not a silver bullet … it’s a v.1 of something that has legs to continue on in future releases.  It addresses the issues with code running in proc.  It has reasonable coverage of APIs developers need and it is based on protocols and standards that are far more easily leveraged across the internet, from other platforms and by new developers.  Read my post about why I like the new plumbing here: http://looselytyped.net/2012/07/17/sharepoints-new-app-model-and-marketplace-great-for-developers/

Apps
This is another one I am going to be disliked for by some. 

I don’t like Apps … yet. 

Why do I say “yet”?  In my view the options they offer for well thought out enterprise business applications are too limited for practical use just yet. 

Predominantly this falls back to one major issue I have with them.  SharePoint UX integration.  There just isn’t enough of it yet.  Apps today are limited to App Parts (iFrame in a web part), basic ribbon buttons/ECB menus & that’s about it.  You can’t deeply integrate your application into the SharePoint UX in ways you can with full trust code on prem.  To build real world Enterprise grade applications you need this level of capability. 

Hey CJ … don’t be dissing on the apps bro …

Look … I get it … the app model is 100% needed.  We need a way to add functionality to SharePoint in a safe and secure way that works in SharePoint Online.  Lets be clear here, Apps are designed for SharePoint Online first and foremost.  The problems get worse trying to do them on-prem.

I hold out great hope that the App model develops out further quickly.  I really do.  I would love it if the App model offered deeper integration with SharePoint UX across the board, better event integration (remote event receivers with guaranteed delivery for example), and broader API coverage.  In time I am sure it will get there.  But for now I don’t see many enterprise grade apps landing in the marketplace for a while.  I am sure there will be plenty of nice less business critical apps/widgets however.

Office is a different story entirely.  Office needed a new developer model ASAP.  I don’t know if you have ever had to write an Office addin … but OMG its bad.  Even through the App model for Office is also somewhat limited today I think it’s a good step in the right direction for Office.  Anything but COM addins!! 🙂

V.Next – To the cloud!
What will be fascinating to see going forward is how SharePoint evolves from here. 

It wouldn’t surprise me if 2013 was the last major release of SharePoint for on-prem*.

* I have no insider knowledge on this, in case you are wondering 🙂  This is purely my personal opinion.

Sure, there will be service packs and maybe feature packs, but I don’t personally think we will see a new full release like we saw yesterday. Sad but true (IMHO).  Who knows, maybe SharePoint on-prem on going will be a series of service packs and feature packs 🙂

Microsoft’s reinventing itself into a Devices + Services company.  For good or for worse … that is what Ballmer is out there saying.  Personally, I would rather they stick to Software + Services like MS have been saying well before Apple got into that game and started calling it cool. Topic for another post 🙂

Microsoft (contrary to everyone out there) isn’t stupid.  You don’t make billions of dollars a year being stupid.  It won’t throw the babies out with the bath water (Office and Windows) … so I doubt we will see MS not making an operating system that you can install on any PC hardware you like any time in the near future.  However, my point is that MS are pushing their traditional customers to the cloud. SharePoint is part of that, and as far as a product, not a bad on to go to the cloud (email being the 1st and most obvious, why o why does anyone run Exchange on-prem is beyond me).

Customization
Totally messing with SharePoint from the inside out is going away.  Not in 2013 … but that is the direction it is heading.  This is just a direction at this point, but you can start to see this happening by the lack of investment in SharePoint Designer 2013.  Really the only thing added was some better support for building Workflows. (PS: why o why didn’t they build this in a browser based way is boggling.)  There are still things SharePoint Designer does that you cant do right now via the browser … but over time that will close and it wouldn’t surprise me if 2013 was the last version of SPD.  Sadly the same thing goes for InfoPath.  Not much happened sadly. Access is clearly trying to make a comeback and InfoPath will suffer for it.  This is really really sad to me.  InfoPath is the only solution for customizing workflow task forms and list forms.  SharePoint needs a solution to create custom forms that integrate with Workflow and Lists period.  I guess Nintex will be selling a boat load of software to fill these gaps.

If you want a sample of how passionate the SharePoint community is about this direction in SharePoint you only have to read this thread in Yammer: https://www.yammer.com/spyam/threads/193828574?m=1135076296&message_id=193828574

Conclusion
I am totally thrilled to see SharePoint 2013 and Office 2013 hit RTM.  I am SO pumped to go to SPC this year and see all the presentations about it.

I really do think this is release is an excellent step in the right direction for developers, despite all the pain and suffering we will all go through for the next 12 months while everyone get used to the new model & old SharePoint people get over the change. No one likes change, but its desperately needed in my view.

There are bunch of amazing new features, too many to list … but I think my personal favorite is Metadata driven navigation.  I think that is the most exciting feature.  It has applications for public facing sites sure … but the KILLER use is for Intranets.  Finally a reasonable solution for that wee feature all us old guys miss from Content Management Server … Connected Pages 🙂

Congrats again to MS for getting it done on 10/11/12!!

-Chris.