{"id":706,"date":"2020-10-13T13:36:20","date_gmt":"2020-10-13T20:36:20","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=706"},"modified":"2020-10-13T13:36:20","modified_gmt":"2020-10-13T20:36:20","slug":"cppintro","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/cppintro\/","title":{"rendered":"Introducing the new Azure SDK for C++ Beta"},"content":{"rendered":"<p>The new <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\/tree\/azure-core_1.0.0-beta.1\/sdk\/core\/azure-core\">Azure SDK for C++<\/a> is idiomatic to the C++ language and ensures consistency in behavior and API surface when communicating with Azure services.<\/p>\n<p>Some of the key features of the Azure C++ SDK are:<\/p>\n<ul>\n<li>\n<p>Customers of our SDK compile our source code along with their own<\/p>\n<\/li>\n<li>\n<p>The SDK is easily consumable by environments using CMake<\/p>\n<\/li>\n<li>\n<p>We target C++ 14 and test for x86, x64, ARM32, and ARM64 CPU architectures using gcc, clang, XCode, &amp; MS Visual C++ compilers<\/p>\n<\/li>\n<li>\n<p>We support Linux, Windows, and Mac platforms<\/p>\n<\/li>\n<li>\n<p>We fully embrace exception handling to report errors from SDK methods<\/p>\n<\/li>\n<li>\n<p>We offer very few abstractions making our code easy to understand and debug<\/p>\n<\/li>\n<\/ul>\n<h2>Azure Core<\/h2>\n<p>At the heart of our SDK is what we refer to as Azure Core. This code defines several data types and functions for use by the client libraries that build on top of it, such as the Azure Storage Blobs client library. Here are just some of Azure Core\u2019s features:<\/p>\n<ul>\n<li>\n<p>A replaceable HTTP stack allowing customers to select and use the HTTP stack that they desire. We ship a libcurl transport adapter which enables our SDK to work on all supported CPU architectures and OSes. We will soon have a WinHTTP transport adapter specifically for Windows.<\/p>\n<\/li>\n<li>\n<p>Like our other language SDKs, Azure Core offers an HTTP pipeline of policies which can be configured at runtime.<\/p>\n<\/li>\n<li>\n<p>All I\/O operations are cancelable using our own Context mechanism.<\/p>\n<\/li>\n<li>\n<p>We have our own easy-to-use <code>BodyStream<\/code> base class enabling the upload and download of byte streams typically used by blobs and files. Using the decorator pattern, you can create your own <code>BodyStream<\/code>-derived classes to compose features such as progress reporting, encryption, compression, and so on.<\/p>\n<\/li>\n<\/ul>\n<p>In addition to the above features, Azure Core provides features available to client libraries written to access other Azure services. Customers use these features indirectly by way of interacting with a client library. By providing these features in Azure Core, the client libraries built on top of us share a common implementation and many features behave identically across client libraries. For example, Azure Core offers a standard set of credential types and an HTTP pipeline with logging, retry, and telemetry policies.<\/p>\n<h2>Example Code using the C++ Storage Blob Client Library<\/h2>\n<p>The code below demonstrates how to create a storage blob container, create a blob in that container by uploading a data buffer in memory, and how to download the blob\u2019s data back to a memory buffer. The comments in the code describe what is happening.<\/p>\n<pre><code class=\"c++\">#include \"azure\/storage\/blobs\/blob.hpp\"\n\n#include &lt;iostream&gt;\n#include &lt;string&gt;\n\nusing namespace Azure::Storage::Blobs;\n\nint main()\n{\n  \/\/ Create a BlobContainerClient from a connection string & container name\n  auto containerClient = BlobContainerClient::CreateFromConnectionString(\n      \"[StorageConnectionString]\",\n      \"sample-container\");\n  try\n  {\n    containerClient.Create();  \/\/ Attempt to create the blob container\n  }\n  catch (std::runtime_error& e)\n  {\n    \/\/ The container may already exist\n    std::cout &lt;&lt; e.what() &lt;&lt; std::endl;\n    return -1;\n  }\n\n  \/\/ Create a BlockBlobClient from a container & blob name\n  BlockBlobClient blobClient = containerClient.GetBlockBlobClient(\n    \"sample-blob\");\n\n  {\n    \/\/ Create blob whose content is the specified data buffer\n    std::string blobContent;\n    blobContent.resize(50 * 1024ULL * 1024, 'x');  \/\/ 50 MB of x\n\n    blobClient.UploadFrom(\n        reinterpret_cast&lt;const uint8_t*&gt;(blobContent.data()),\n        blobContent.size());\n  }\n\n  {\n    \/\/ Download the blob\u2019s contents to a data buffer\n    blobClient.DownloadTo(\n      reinterpret_cast&lt;uint8_t*&gt;(&blobContent[0]), blobContent.size());\n  }\n\n  return 0;\n}\n<\/code><\/pre>\n<p><!-- FOOTER: DO NOT EDIT OR REMOVE --> <div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/aka.ms\/azsdk\/releases\" target=\"_blank\">Azure SDK Releases<\/a><\/div><\/p>\n<h2>Azure SDK Blog Contributions<\/h2>\n<p>Thank you for reading this Azure SDK blog post! We hope that you learned something new and welcome you to share this post. We are open to Azure SDK blog contributions. Please contact us at <a href=\"&#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;&#x61;z&#115;&#x64;&#107;&#x62;&#108;&#x6f;&#103;&#x40;&#109;&#105;&#x63;&#114;&#x6f;&#115;&#x6f;&#102;&#x74;&#46;&#x63;o&#109;\">&#x61;z&#115;&#x64;&#107;&#x62;&#108;&#x6f;&#103;&#x40;&#109;&#105;&#x63;&#114;&#x6f;&#115;&#x6f;&#102;&#x74;&#46;&#x63;o&#109;<\/a> with your topic and we&#8217;ll get you setup as a guest blogger.<\/p>\n<h2>Azure SDK Links<\/h2>\n<ul>\n<li>Azure SDK Website: <a href=\"https:\/\/aka.ms\/azsdk\">aka.ms\/azsdk<\/a><\/li>\n<li>Azure SDK Intro (3 minute video): <a href=\"https:\/\/aka.ms\/azsdk\/intro\">aka.ms\/azsdk\/intro<\/a><\/li>\n<li>Azure SDK Intro Deck (PowerPoint deck): <a href=\"https:\/\/aka.ms\/azsdk\/intro\/deck\">aka.ms\/azsdk\/intro\/deck<\/a><\/li>\n<li>Azure SDK Releases: <a href=\"https:\/\/aka.ms\/azsdk\/releases\">aka.ms\/azsdk\/releases<\/a><\/li>\n<li>Azure SDK Blog: <a href=\"https:\/\/aka.ms\/azsdk\/blog\">aka.ms\/azsdk\/blog<\/a><\/li>\n<li>Azure SDK Twitter: <a href=\"https:\/\/twitter.com\/AzureSDK\">twitter.com\/AzureSDK<\/a><\/li>\n<li>Azure SDK Design Guidelines: <a href=\"https:\/\/aka.ms\/azsdk\/guide\">aka.ms\/azsdk\/guide<\/a><\/li>\n<li>Azure SDKs &amp; Tools: <a href=\"https:\/\/azure.microsoft.com\/downloads\">azure.microsoft.com\/downloads<\/a><\/li>\n<li>Azure SDK Central Repository: <a href=\"https:\/\/github.com\/azure\/azure-sdk#azure-sdk\">github.com\/azure\/azure-sdk<\/a><\/li>\n<li>Azure SDK for .NET: <a href=\"https:\/\/github.com\/azure\/azure-sdk-for-net\">github.com\/azure\/azure-sdk-for-net<\/a><\/li>\n<li>Azure SDK for Java: <a href=\"https:\/\/github.com\/azure\/azure-sdk-for-java\">github.com\/azure\/azure-sdk-for-java<\/a><\/li>\n<li>Azure SDK for Python: <a href=\"https:\/\/github.com\/azure\/azure-sdk-for-python\">github.com\/azure\/azure-sdk-for-python<\/a><\/li>\n<li>Azure SDK for JavaScript\/TypeScript: <a href=\"https:\/\/github.com\/azure\/azure-sdk-for-js\">github.com\/azure\/azure-sdk-for-js<\/a><\/li>\n<li>Azure SDK for Android: <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-android\">github.com\/Azure\/azure-sdk-for-android<\/a><\/li>\n<li>Azure SDK for iOS: <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-ios\">github.com\/Azure\/azure-sdk-for-ios<\/a><\/li>\n<li>Azure SDK for Go: <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-go\">github.com\/Azure\/azure-sdk-for-go<\/a><\/li>\n<li>Azure SDK for C: <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-c\">github.com\/Azure\/azure-sdk-for-c<\/a><\/li>\n<li>Azure SDK for C++: <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\">github.com\/Azure\/azure-sdk-for-cpp<\/a><\/li>\n<\/ul>\n<p><!-- FOOTER: DO NOT EDIT OR REMOVE --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post introduces the new Azure SDK for C. Well discuss its goals, supported compilers\/platforms, and our Azure Core component which provides common functionality to all HTTP client libraries.<\/p>\n","protected":false},"author":39618,"featured_media":707,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[706,738],"class_list":["post-706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-azuresdk","tag-storage"],"acf":[],"blog_post_summary":"<p>This post introduces the new Azure SDK for C. Well discuss its goals, supported compilers\/platforms, and our Azure Core component which provides common functionality to all HTTP client libraries.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/users\/39618"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=706"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/706\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/707"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}