Platinum Partner
dotnet,cloud,microsoft,tools,windows,data access,azure

AZR331 – Casablanca: C++ on Azure

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).

IMG_2309 IMG_2310
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.

IMG_2313 

Casablanca Task Libraries

IMG_2314

[Demo] Mandelblot example rendered from locally via Casablanca.

IMG_2315 IMG_2316

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

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}