Project Astoria a hit at TechEd

There is a buzz here at TechEd about Project Astoria. The reason is that it promises to simplify development of web applications that deal with data, which is most of them. Astoria is a REST API for ADO.NET, and hooks into the new Entity Framework object-relational mapping layer. Therefore, it solves two problems in one go.

Here’s a quick look at how it works. Let’s assume that you have a database which stores some information you want to present in your web application. Step one is to use Visual Studio to generate an Entity Data Model from your database.

Next, you tweak the model so that it looks as close as possible to the objects you are storing. The framework should deal with the complexities of mapping collections to linked tables and so on.

Now you create a new ADO.NET Data Service (sadly, this may well be the official name for Astoria), and point the service at your model. By default a new service does not expose any data, for security reasons, but by writing an InitializeService method you can configure which objects you want to publish.

Run the service, and the objects in your model are now URL-addressable. It’s pretty flexible. For example:

[serviceurl]/Products : return all the products (yes, you can do paging).

[serviceurl]/Products[2]: return the product with an ID of 2.

[serviceurl]/Products[Color eq ‘Blue’]: return all the blue products.

[serviceurl]/Customers[2]/Orders/:return all the orders for the customer with an ID of 2.

The data comes back in either ATOM or JSON format. Naturally, each element in the returned data includes its URL. Let’s say you have an AJAX application so you are calling this service from JavaScript. Iterating through the results and populating an HTML list or table is easy, especially as Astoria includes a client JavaScript library. There is also a client library for .NET applications. You can also add or update data with HTTP PUT, or remove it with DELETE.

You can extend your Astoria API by adding arbitrary methods that have the [WebGet] (or presumably [WebPut] or [WebDelete]) attribute. You can also add “interceptors” – code that gets called just before requests are executed, to enable validation or custom security.

Presuming it works as advertised, Astoria is a more natural and concise way to handle data than SOAP web services, and easier than devising your own techniques. It should work well with other technologies such as Adobe’s Flex. It will play nicely with mash-ups, since many other services out there use ATOM or JSON. it is a natural fit with AJAX and will work well with Silverlight – see http://www.silverlightdata.com [Silverlight 1.1 Alpha required] for an example.

Astoria will not be finished in time for the initial release of Visual Studio 2008, though reading between the lines it might be done in time for SQL Server 2008. It will work with any database server for which there is an Entity Framework provider. I was assured that creating such a provider is relatively easy, if you already have an ADO.NET 2.0 provider, so it is reasonable to expect wide support.

I think this will be popular.

Technorati tags: , , , , ,

Why Silverlight?

I noticed this question in a comment to Rob Blackwell’s Reg article on Silverlight:

…given that MS never does anything without a commercial reason … why Silverlight? What sales will it make? What competition will it kill? As far as I can see, there’s nothing that will tie SL exclusively to a particular MS product.

Answer: it’s all about the platform stack. Microsoft does not want to cede this space to Adobe and Flash, because it is strategic. Use Flash, use Adobe’s tools rather than Visual Studio, use the Java-based LiveCycle and JEE rather than ASP.NET and Windows Server. Use Silverlight, use Visual Studio, ASP.NET, XAML, SQL Server, all the Microsoft stuff.

What about the Internet as an advertising platform? Flash/Silverlight is the client runtime.

What about the Internet as a broadcasting platform? Same story.

I speculated recently about the future of gaming.

Silverlight is partly defensive. In other words, less about “what sales it will make?” than about, “what sales will it avoid losing?” Web developers need to support cross-platform clients; if Microsoft cannot provide the tools and server-side platform to make that work, developers will look elsewhere.

I picked up a hint here at Tech-Ed that SQL Server Compact Edition may find its way into a future Silverlight. A cross-platform local database store makes a lot of sense; Adobe already has this in the form of SQLite. If Adobe’s AIR proves popular, Microsoft could relatively easily push Silverlight in that direction as well, providing a way of running Silverlight outside the browser.

Doesn’t this undermine Windows? Maybe a little, and I am sure this is a point of debate within Microsoft, but it is worth it.

Silverlight’s big problem: devices. Flash on iPhone: possible, even likely. Silverlight on iPhone, Nokia? A stretch.