“Casablanca is a Microsoft incubation effort to support cloud-based client-server communication in native code using a modern asynchronous C++ API design. Think of it as Node.js, but using C++. Casablanca gives you the power to use existing native C++ libraries and code to do awesome things on the server. Come and watch John Azariah and Mahesh Krishnan show you how it is done”
Presented by John Azariah and Mahesh Krishnan
Disclaimer: These are conference session notes I compiled during various sessions at Microsoft Tech Ed 2012, September 11-14, 2012. The majority of the content comprises notes taken from the presentation slides accompanied, occasionally, by my own narration. Some of the content may be free hand style. Enjoy… Rob
Arrived about ten minutes late due to delays in checking out of the hotel. John’s now in the process of compiling and running a Hello World sample.
The Node Influence on Casablanca
- Asynchronous, non-blocking I/O
- Powerful libraries (many external modules)
- Simplicity
Sample Node.js approach to a hello world HTTP response looks very similar in C++.
The http namespace used in C++ is out of Casablanca.
Node.js sample:
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
..and a C++ Casablanca version:
http_listener listener =
http_listener::create("http://localhost/path_1",
[](http_request request)
{
request.reply(status_codes::OK, "Hello, World!");
});
listener.open();
Some Inclusions:
- Web
- RESTful services
- JSON
- The Cloud
- SDK for accessing Azure storage
[Demo] Serializing JSON, implementing a RESTful interface and hooking to Azure
- Mapping HTTP verbs to actions, e.g.
- Read = GET,
- Update = PUT,
- Insert = POST,
- Delete = DELETE
Possibly using the following syntax:
MyListener::MyListener(const http::uri& url) :
m_listener(http_listener::create(url))
{
m_listener.support(methods::GET,
std::tr1::bind(&MyListener::handle_get,
this,
std::tr1::placeholders::_1));
m_listener.support(methods::PUT,
std::tr1::bind(&MyListener::handle_put,
this,
std::tr1::placeholders::_1));
m_listener.support(methods::POST,
std::tr1::bind(&MyListener::handle_post,
this,
std::tr1::placeholders::_1));
m_listener.support(methods::DEL,
std::tr1::bind(&MyListener::handle_delete,
this,
std::tr1::placeholders::_1));
}
Demonstration of all of the above shows that JSON serialization in/out is quite seamless (at this stage).
Handling JSON & Using Cloud Storage
C++ Specific Advantages
[Demo] Text to Speech Demo
Wow, I haven’t seen some of those pre-processor and #pragma statements in a long time.
[Demo] PhotoSynth Web Service
Photosynth has a web service implementation now. Uploading multiple photos and getting back the panorama is quite cool.
Here’s the panorama taken at the session.
Casablanca Task Libraries
[Demo] Mandelblot example rendered from locally via Casablanca.
The next big thing coming out of the Casablanca Team is GPU processing.
Summary
- Casablanca is an incubation effort
- Allows you to write end-to-end Azure apps in C++
- If you are already programming in C++ you can migrate your apps to Azure
2 thoughts on “AZR331 – Casablanca: C++ on Azure”
Interesting writeup. Microsoft seem to be pushing C++ a bit recently, why that and not C#/.NET I wonder?
Hey I am so delighted I found your website, I really found you by mistake, while
I was searching on Digg for something else, Anyhow I am here now and would just like to say cheers for a marvelous post and a all round interesting blog (I
also love the theme/design), I dont have time to go through it all at the minute but
I have book-marked it and also added your RSS feeds, so when I have time I will be
back to read more, Please do keep up the excellent jo.