Live Meeting Presentation Today on Windows Phone 7 + OData + Silverlight + Azure

image

I’m doing a 1.5 hour Live Meeting presentation today at 16:00 ET on these hot topics for the Windows Azure User Group

The audience objectives include:

  • Learn key features of Silverlight, OData & the Windows Azure Platform
  • Learn about preparing an application for use with Windows Azure & SQL Azure
  • Learn stages and ways to deploy a full application to the Windows Azure Platform
  • Learn how Silverlight can interact with Windows Azure Platform technologies.

Register for this hot-topic event and participate remotely.

https://www.clicktoattend.com/invitation.aspx?code=147804

If you are looking for in-depth rapid training on developing for Windows Phone 7 development AND hands-on time with a device, then you should consider registering for the this major 2-day boot camp running across Canada.

Windows Phone 7 Boot Camp

Advertisements

Windows Azure Loves Open Source at Make Web Not War Conference

Microsoft held it’s Make Web Not War conference in Montreal on May 27th 2010.

mwnw[1]

I was asked to present on the Windows Azure Platform for a CodeFest audience consistly largely of open source developers.

Here’s the Windows stack using Azure across from the LAMP stack.

20100606 cross-plat

I discussed how to mix and match a these things, so here’s a summary of some of the interoperability points and resources mentioned at the event.

Windows Azure Storage accessible from .NET and PHP

Windows Azure storage is a hugely scalable storage system with a REST-based interface accessible to systems that can talk XML over TCP.

As well as client libraries for .NET applications, there’s also the Windows Azure SDK for PHP (CTP on CodePlex – BSD License).

Windows Azure Hosting & Tools for ASP.NET apps built with Visual Studio and PHP apps bulit with either Eclipse or the Command Line

Windows Azure provides for scalable hosted applications running within the IIS platform (including FastCGI-enabled interpreters like PHP) as well as native Win32 applications (which could include your open server application listening on TCP ports).

Of course there’s a set of Visual Studio tools for developing ASP.NET applications on IIS.  There’s also Windows Azure Tools for Eclipse (windowsazure4e.org) for developing your PHP application in Eclipse to run under IIS FastCGI on Windows Azure.

And if you don’t want to use an IDE there’s also Windows Azure Command-line Tools for PHP (CTP on CodePlex – BSD License).

SQL Azure accessible from .NET and PHP applications

SQL Azure (talking just minutes – seriously like 3 minutes -  to set up a database in the cloud) provides reliable database storage in the cloud.

You can access this from ADO.NET and ODBC clients using the TDS+SSL protocol.  You can also use the SQL Server Driver for PHP 1.1 (or the 2.0 CTP) to access your cloud database from a PHP application.

MySQL hosted on Windows Azure

Yep, there’s a solution for that too – see the Solution Accelerator for MySQL & PHP on Azure

Getting Started with PHP on Windows Azure

This post will get you started with PHP development in Visual Studio for deployment to Windows Azure.

Using the FastCGI capabilities of IIS you can run PHP application on IIS and Windows Azure (in your local Development Fabric on in the Windows Azure cloud).

So, here’s how to create a simple PHP application in Visual Studio 2010 on Windows 7.

If you want to see this in video, check out my screencast interview with Dot Net Rocks TV on Azure and go to point 48:40.

  • Download the latest Windows ZIP files from http://windows.php.net/download/ (currently 5.3.2).  You should get for the VC9 x86 Non Thread Safe version.  The FastCGI system on IIS makes the use thread-safe.  Unzip the files into a folder somewhere on your system and rename the folder "PHP".
  • Ensure you have everything for IIS and CGI (i.e. FastCGI) is activated on your system for local development. 
  • Install the latest Azure SDK (checking the system requirements) – currently 1.1 (Feb 2010).
  • Start Visual Studio 2010 (which must be in run as an Administrator for the current version of the SDK) and create a new VS Cloud Project…

azphp1

  • Add the CGI Web Role…

azphp2

  • Open an Explorer window and locate your downloaded and extracted PHP folder.  Do a Copy on the PHP folder.
  • Open the folder for the web project…

azphp3

  • Paste the PHP folder (and therefore subfolders) into the web project folder and then select the Show All Files option in Solution Explorer so you can see the pasted PHP folder…

azphp4

 

  • Use the "Include in Project" option on the php folder to include it in project files, and therefore in the files deployed to Azure.

azphp5

  • Edit the Web.roleconfig file, (putting a new <application/> tag in place like this which tells IIS (locally or in the cloud) about the FastCGI interpreter for PHP…

azphp6

  • Edit Handers section of the Web.config file to include this new <add/> tag which tells IIS to use the PHP interpreter for files ending with .PHP…

 azphp7

  • Also add the new <defaultDocument/> tag above to set up "index.php" as the default document for the web application.
  • Finally add a basic index.php file using Add New Item on the web project; since there is no .PHP item – use a .TXT item (in the General category) and give the new file a .PHP extension…

azphp8

  • Enter this basic PHP code:

<? phpinfo(); ?>

  • Start up the application and you should see something like the following:

azphp9

You can now deploy this (or a real application) to Azure using the Publish function on the Cloud project as usual.

Check out this MSDN page for general help on using FastCGI interpreters with Azure.

Enjoy! 🙂

Microsoft and Open Source Communities are sponsoring the Make Web Not War conference on May 27th 2010, showcasing the latest cross-platform techniques and technologies, including presentations, panels, workshops, a codefest, the FTW coding competition and a party!  Open Data, HTML 5, PHP, JQuery, Mobile, SEO and the Cloud, are amongst the topics being covered.  Speakers and panelists will include myself, Microsoft Canada team members and many open source experts.

Make Web Not War

Bringing Azure+OData+Silverlight Goodness to Open Data Apps in Ottawa

On Saturday April 24th 2010, at Open Data Ottawa Hackfest, a team built the ‘OttGuide’ application (here showing 6000+ bus stops on the Ottawa public bus transit network), built on the Open Data Application Framework using Silverlight and Bing Maps, accessing an OData service built with .NET 3.5 and hosted on Windows Azure and SQL Azure.  For more on open data and cross-platform togetherness, consider for the Make Web Not War conference on May 27th 2010 in Montreal.

odata1

This passed Saturday Apr 24th 2010, the very successful Open Data Ottawa Hackfest took place for the first time in Ottawa City Hall organised by Edward Ocampo-Gooding and friends.  A large number of people (enough to exhaust the free t-shirt supply) attended for 4+ hours from different fields (developers, designers, librarians, statisticians. media and city officials).  The event included opening presentations, a hack fest where attendees worked on applications showing use of Ottawa data and closed with a series of presentations showing the fruits of the attendees’ labour.

Prior to the event, the City of Ottawa (unlike cities like Vancouver and Edmonton) hadn’t officially published municipal data or a data publication policy.  This meant that attendees to the hackfest were using various interesting methods to get data for their application from screen scraping to manual data re-enty.

I had the opportunity to talk at length with the city’s CIO, Guy Michaud, and discovered that the city is in fact on the verge of agreeing a policy and then immediately publishing a few initial sets of satic data, most likely sometime in May.  It’s quite possible that the hackfest event helped push this action ahead, but Guy is clearly a guy with forward-looking ideas on the issue of data publishing.

I was told about the event a few weeks ago by friend and Microsoft Canada IT Pro Advisor Rick Claus who was planning on attending.  So, in those weeks, I took a look at some of the work that has been done to obtain Ottawa municipal data and at open data work in general.  In particular I looked in 3 things:

odata2

  • Craig Davey had done extensive work on taking Google-compatible data published on the City’s OCTranspo site, augmenting it, converting it to GTFS format and publishing it with updates in a feed.
  • I had been familiar for some time with Microsoft’s open protocol for providing access to queryable and updateable data sets in a RESTful way – OData.  I did further research into this.  OData builds on ADO.NET Data Services and is fully incorporated into WCF Data Services within the recently released .NET 4 framework.  OData is designed to be consumed (or produced) by many different clients on many platforms. There are client libraries available or in the works for .NET (3.5 with an update & 4.0), Silverlight 4.0, iPhone, Javascript, Windows Phone 7, PHP & Java.  In fact, any client that can make web requests and handle XML can access OData-based services.

The night before the event, on a total whim, I decided to knock up an OData service exposing OCTranpo data, so I: 

  • started with Craig’s GTFS-format data provided as CSV files in a ZIP file. 
  • created an ADO.NET Entity Framework Model in a new .NET 3.5 Class Library project in Visual Studio 2010 to represent the GTFS data with entities and relationships
  • used the designer tools to generate DDL script to create the database schema
  • generated the schema using the script
  • created a database in my local SQL Server 2008 server
  • wrote code to import the CSVs and use the ADO.NET Entity Framework classes to import the data which was taking 3+ hours
  • wrote new code to import the CSVs with the SQL using bulk copy class bypassing the model which did the import of over 2 million bus stop time rows in a few minutes
  • added a WCF Service project and removed the default service from the project template
  • added a WCF Data Service item, setting it up to use the class of the entity model I created and providing read access to all entities
  • copied the connection string from my entity model class library app.config into the WCF Service web.config
  • tested my OData service using the OData URL query syntax, here showing a list of all stops… but this could be queried to find things like a nearby stop (from GPS coordinates), the bus times for a stop, the trips (e.g. ‘saturday service to ABC on route x’) and routes (i.e. bus number) going through a stop, find the stops on a trip, when a specific service gets somewhere, or even for full journey planning, etc.

odata3

  • re-opened by solution as administrator so I could use the Azure Cloud tools
  • added a Windows Azure cloud project with no roles and added my existing WCF Service project to the roles
  • tested OData access running in the local Azure Development Fabric connecting to my local SQL Server database
  • created a SQL Azure server and database in the cloud using the SQL Azure portal
  • connected to SQL Azure using SQL Server Management Studio and created my database schema using a modified version of my existing DDL script (removing USE statements)
  • used the bcp utility to export tables from my local database to local files and then again to import those up to SQL Azure
  • updated the connection string in my web.config to use the SQL Azure database
  • tested OData access running in the local Azure Development Fabric connecting to the SQL Azure database
  • published by cloud project in Visual Studio, created a Hosted Service on the Windows Azure portal and deployed the application to Azure using the portal
  • tested OData access running in on Windows Azure connecting to the SQL Azure database

So I had an OData service exposing the OCTranspo bus routes, trips, stops and trip stop times – sweet!

When I got to the event at 3:15pm, I met up with Christian, Rick & John Weigelt (Microsoft Canada’s National Technology Officer).  They were looking at the VanGuide application and potential Ottawa data sources to hook up to it as a demonstration.  Demonstrations were due at 4pm.  Of course, as I’ve stated, good data sources were hard to find because the City of Ottawa hadn’t published any official open data sets.

OData service to the rescue…?

We set to work on integrating my sample OCTranspo OData service (which was already running the cloud), into the the Open Data Application Framework, transforming the VanGuide application into an ‘OttGuide’ application.  The framework includes a Silverlight application project that includes dynamic handling of web-based data sources (the dynamic list of landmark sources on the left of the UI) and asynchronous data retrieval and handling code (that takes KML and other format data and adds data points as map points on a Bing Maps Silverlight control).

We wanted to make this Ottawa specific, wo we went ahead and:

  • modified the data source list to show an entry for OCTranpo and removed the other ones
  • removed other Vancouver-specific map region options
  • added custom code to handle OCTranpo GTFS entities in a feed (our OData feed) using Linq to XML to create Landmark instances that the framework already understands
  • made the application zoom in on Ottawa
  • made some other cosmetic changes for Ottawa

The result is the application you see at the start of this blog entry.  For full disclosure, we got the full bus stop retrieval and map point creation working literally 1 minute after the public presentation section finished, but Christian managed to demonstrate the VanGuide version and the OData feed.

The ODAF framework means that an OttGuide application user can select bus stops, rate them, add comments, etc.  It would be relatively easy to add datasets for other ‘landmarks’ (e.g. water foundations, tourist spots, parks and even pot holes).

The same OData service could be used on clients like the new Windows Phone 7 platform to give bus services users valuable travel information :).  Perhaps more on that later…

Open data and open web technologies are current hot topics and OData is a great protocol to bring things together on many platforms.  Silverlight is a great technology to deliver rich user experiences on many platforms using data sources from a variety of platforms. 

Microsoft and Open Source Communities are sponsoring the Make Web Not War conference on May 27th 2010, showcasing the latest cross-platform techniques and technologies, including presentations, panels, workshops, a codefest, the FTW coding competition and a party!  Open Data, HTML 5, PHP, JQuery, Mobile, SEO and the Cloud, are amongst the topics being covered.  Speakers and panelists attending include myself, Microsoft Canada team members and many open source experts.

Make Web Not War

All I want for Mix-mas this March at Microsoft Mix10

So the seasonal gift giving has now passed, but I’m hoping for a few good prezzies for Microsoft’s Mix conference.

  • Windows Mobile 7 rocking a .NET ‘Mobile’ (not compact) Framework programmable Silverlight 3+ interface, Xbox mobile games (like Zune games programmable with the free XNA Game Studio), Zune Interface, Media Center extender abilities, and a marketplace with no publishing gauntlet for music, games and apps, and real devices available by Oct 2010.  A full marketplace in Canada is a must!
  • ‘Visual Mobile 2010 Express Edition’ – I don’t need this since I’ll have VS 2010 Premium/Ultimate, but Microsoft needs to release a free mobile development tool (with Silverlight designer support presumably) that will launch 100,000 apps
  • Decent replacement for the Live Framework (which was withdrawn) including free Bing Maps API usage up to a decent ceiling
  • Consistent mobile and desktop Live Services and Framework experience
  • Live Mesh Release (with better-than-hopeless user documentation)
  • Better free and on-ramp deal pricing for the Windows Azure Platform
  • Microformat & Live Clipboard SDK for IE 9.  Ray Ozzie blogged and tinkered (including a subsequent SDK and runtime) about ‘Wiring the Web’ with a ‘Live Clipboard’ using microformats back in 2006.  Skip to the present day and go to this Microsoft Canada blog post this week promoting my Mix session proposals (thanks Joey) and look at the Mix-powered Microformat tool that appears at the top left ;-)  Accelerators for IE8 just didn’t do it.
  • Oh, and of course for one or more of my Mix sessions (see below) to be selected by the public through the voting that ends tonight! 🙂

Not too much to ask for right?

 

Looking to learn more about the Windows Azure Platform, Silverlight, Windows Touch or Windows Identify Foundation?

If you’d like to see these sessions in person at Microsoft’s Mix 2010 conference or the recordings that will likely be made available for free later on, please vote for the sessions before January 15th 2010, by going to the site, adding the 3 sessions to you ballot and submitting it

Quick Tip to Retain ASP.NET dynamic Recompile Changes During Azure Debugging

One of the major benefits of the Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio is the ability to operate an Azure Development Fabric and Azure Development Storage emulation on your local machine.  Pressing F5 in a Visual Studio Azure project deploys and runs your application in an environment emulating the real Windows Azure.  This is somewhat similar to the ASP.NET Development Server that starts up and somewhat emulates IIS (or other ASP.NET hosting environment) when you debug an ASP.NET application.

This is great, but can also create an efficiency bottleneck during development.

If you are debugging a regular ASP.NET application and you need to make changes, in many cases you can stay in debug mode;  you can edit an ASPX page or other assets (including CSS) and simply refresh the already running web browser instance to see you changes.  In the case of the ASPX page having changed, it is dynamically recompiled when you next access it.  This works because the ASP.NET Development Server is pointing at your development files.  This efficient cycle is lost when you start debugging with the Windows Development Fabric…

When you debug (or run) an Azure project in Visual Studio, your application is built into a package that is ‘deployed’ to the local Azure emulation.  The emulation therefore uses its own copy of the files.  Making changes to the file in Visual Studio while debugging, only updates the copies under Visual Studio’s control – they are neither repackaged nor redeployed.  The Azure Development Fabric has no idea that they’ve changed.  So, you have to stop debugging, re-launch, wait for the new package to build and deploy, and then get back to the same place in the application.

Here’s what likely amount to a satisfactory workaround before you are ready for the emulation stage:  create a mock for the Data Access Layer that deals with Windows Azure Storage and debug your project outside of the Azure Development emulation.  You lose role instance configuration, but you can go back to using the ASP.NET Development Server.  You may also lose the Azure diagnostic logging – but you can mock that too.

Note:  If you are using SQL Azure, for the most part you can use a regular local SQL Server in place.

I’m not suggesting you mock the interfaces to the Azure APIs directly.  Your application may well have a Data Access Layer which (when following best practices), will likely have an interface.  I suggest you create an object to mock this using the same interface or perhaps use one of the available mocking frameworks.

To facilitate the selection of the polymorphic DAL objects (real or mock) in one code-base you’ll likely want to make your application smart enough to know if it’s running in the Azure environment (Microsoft or local emulation) or not.  My previous post on the topic explains this idea.

You’ll need an interface that suits the operations of your DAL such as this example (where WallMessage is defined elsewhere)…

image

a mock object (such as the example shown below) and a real object (not shown) that both implement the interface…

image

and then calling code that first selects the mock or real object to use based on environment detection……

image

after which you go on to use properties and methods on the selected interface oblivious to the implementation being used.

This is just a basic example and as mentioned, there are some very good Mocking frameworks as well as Dependency Injection frameworks available that ease this kind of setup in large or complex solutions.

The code shown is from the sample Silverlight application I provide (including source code) in my Azure Deployment Guide, already used by 100s of people to successfully deploy their first Azure application.

I hope you found this tip useful 🙂 If so, and you’re reading this on January 15th 2010 then please vote for my Mix 2010 conference submissions today! :)  Thank you.

Looking to learn more about the Windows Azure Platform, Silverlight, Windows Touch or Windows Identify Foundation?

If you’d like to see these sessions in person at Microsoft’s Mix 2010 conference or the recordings that will likely be made available for free later on, please vote for the sessions before January 15th 2010, by going to the site, adding the 3 sessions to you ballot and submitting it

Quick Tip for Detecting Azure Environment During Your Development Cycle

Given the Azure tools and portal for Visual Studio 2008, there are 4 likely modes of execution during your development cycle:

  1. Testing in Visual Studio (with no Azure environment)
  2. Testing in Visual Studio using the local Azure Development Fabric/Storage
  3. Staged on the Azure portal
  4. Deployed on the Azure portal

#1 mostly applies when you have an application that you are porting, or you are development components that may become part of the application.

At times you may find it useful to know if you are running inside or outside of the Azure environment (i.e. 1 vs. 2/3/4).

image

Providing you have included the appropriate assembly reference, you can use this API to detect your environment and take appropriate action while developing and testing your components at the stages above.

Looking to learn more about the Windows Azure Platform, Silverlight, Windows Touch or Windows Identify Foundation?

If you’d like to see these sessions in person at Microsoft’s Mix 2010 conference or the recordings that will likely be made available for free later on, please vote for the sessions before January 15th 2010, by going to the site, adding the 3 sessions to you ballot and submitting it