AZR 331 Casablanca C on Azure Mahesh Krishnan
AZR 331 Casablanca: C++ on Azure @Mahesh. Krishnan Principal Consultant Readify @John. Azariah Senior Architect MYOB
What’s covered
demo Getting started
Node. js Hello World example var http = require('http'); http. create. Server(function (request, response) { response. write. Head(200, {'Content-Type': 'text/plain'}); respose. end('Hello World!'); }). listen(8080, '127. 0. 0. 1');
Casablanca Hello World example using namespace http; http_listener: : create("http: //localhost: 8080/", [](http_request) { return request. reply(status_codes: : OK, "text/plain", "Hello World!"); }). listen();
demo ‘nuff talk. Let’s see some C++
demo RESTful Azure Service
using namespace http: : json; . . . value json. Obj = value: : object(); json. Obj[L"Isbn"] = value: : string(isbn); json. Obj[L"Title"] = value: : string(title); . . . request. reply(http: : status_codes: : OK, json. Obj);
Json => C++ object using namespace http: : json; . . . value json. Value = request. extract_json(). get(); wstring isbn(json. Value[L"Isbn"]. as_string()),
Connecting to Azure storage_credentials creds(storage. Name, storage. Key); cloud_table_client(table. Url, creds); cloud_blob_client(blob. Url, creds); cloud_queue_client(queue. Url, creds);
Reading from table storage cloud_table(table_client, table. Name); query_params; auto results = table. query_entities(params). get(). results(); for (auto i = results. begin(); i != result_vector. end(); ++i) { cloud_table_entity = *i; entity. match_property(L"ISBN", isbn); . . . }
Writing to table storage cloud_table(table_client, L"Books"); cloud_table_entity(partition. Key, row. Key); entity. set(L"ISBN", isbn, cloud_table_entity: : String); . . . cloud_table. insert_or_replace_entity(entity);
demo Deploying to the cloud
demo Text to Speech
Azure / IIS Host Binary Serializers JSON Parser & Writer HTTP Client & Listener Win. HTTP Windows Server Apps & Libraries C++ Actors Azure Storage Bing Maps Windows Live TCP Client & Listener Xbox Live Web Sockets Client & Listener PPL Windows 7 / 8 Timers Async File I/O UDP Client & Listener IOCP Possible 3 rd Party Service Host Casablanca Lib Foundation
Casablanca Client APIs with task library http: : client: : http_client(L"http: //url/"); client. request(methods: : GET, L"/foo. html"). then( [=](pplx: : task<http_response> task) { http_response = task. get(); //Do something with response. . . });
Mandelbrot
Wrap-up
http: //msdn. microsoft. com/en-us/devlabs/casablanca. aspx (Casablanca) http: //msdn. microsoft. com/en-us/library/hh 279654. aspx (C++) http: //msdn. microsoft. com/en-us/library/dd 492418. aspx (PPL) http: //social. msdn. microsoft. com/Forums/en-US/casablanca/threads (Forum)
- Slides: 24