{"id":1277,"date":"2021-06-28T11:31:40","date_gmt":"2021-06-28T18:31:40","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=1277"},"modified":"2021-08-25T09:02:23","modified_gmt":"2021-08-25T16:02:23","slug":"intro-cpp-sdk","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/intro-cpp-sdk\/","title":{"rendered":"Introducing the new Azure SDK for C++"},"content":{"rendered":"<p>This month, the Azure SDK team released the new Azure SDK for C++, starting with Azure Core, Identity, and Storage Blobs, Files Shares, and Datalake. We&#8217;re excited to share our guides to getting started and working with the latest libraries!<\/p>\n<h2>Getting the latest libraries<\/h2>\n<p>You can find all of the latest source code on the official <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\">Azure SDK for C++<\/a> repository. Additionally, the following packages are available to install via vcpkg:<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th style=\"text-align: left;\">Latest Version<\/th>\n<th style=\"text-align: right;\">Replaces<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>azure-core-cpp<\/td>\n<td style=\"text-align: left;\">1.0.0<\/td>\n<td style=\"text-align: right;\">&#8211;<\/td>\n<\/tr>\n<tr>\n<td>azure-identity-cpp<\/td>\n<td style=\"text-align: left;\">1.0.0<\/td>\n<td style=\"text-align: right;\">&#8211;<\/td>\n<\/tr>\n<tr>\n<td>auzre-storage-common-cpp<\/td>\n<td style=\"text-align: left;\">12.0.0<\/td>\n<td style=\"text-align: right;\">azure-storage-cpp 7.5.0<\/td>\n<\/tr>\n<tr>\n<td>azure-storage-blobs-cpp<\/td>\n<td style=\"text-align: left;\">12.0.0<\/td>\n<td style=\"text-align: right;\">azure-storage-cpp 7.5.0<\/td>\n<\/tr>\n<tr>\n<td>azure-storage-files-shares-cpp<\/td>\n<td style=\"text-align: left;\">12.0.0<\/td>\n<td style=\"text-align: right;\">azure-storage-cpp 7.5.0<\/td>\n<\/tr>\n<tr>\n<td>azure-storage-files-datalake-cpp<\/td>\n<td style=\"text-align: left;\">12.0.0<\/td>\n<td style=\"text-align: right;\">azure-storage-cpp 7.5.0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Similar to the Azure SDKs for .NET, Java, JavaScript\/TypeScript, and Python, the latest Azure SDK for C++ is divided into smaller libraries that allow for greater control when linking and developing.<\/p>\n<p>At this time, we maintain support for desktop triplets, including:<\/p>\n<ul>\n<li>x86-windows<\/li>\n<li>x64-windows<\/li>\n<li>x64-linux<\/li>\n<li>x64-osx<\/li>\n<\/ul>\n<h2>Installing the Azure Storage library<\/h2>\n<p>Downloading the Azure Storage Blobs, Files Shares, and Datalake libraries through <a href=\"https:\/\/github.com\/Microsoft\/vcpkg\">vcpkg<\/a> is as simple as running the following command:<\/p>\n<pre><code class=\"language-C++\">vcpkg install azure-storage-blobs-cpp[:&lt;triplet&gt;] azure-storage-files-shares-cpp[:&lt;triplet&gt;] azure-storage-files-datalake-cpp:[:&lt;triplet&gt;]<\/code><\/pre>\n<p>Alternatively, developers are welcome to download source code from the <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\">Azure SDK for C++<\/a> repository and compile the code directly using the provided CMAKE files.<\/p>\n<h2>Getting Started with Azure Storage for C++<\/h2>\n<p>The Azure SDK for C++ supports linking with CMAKE by including the following lines in your <code>CMakeLists.txt<\/code> file:<\/p>\n<pre><code class=\"language-C++\">find_package(azure-storage-blobs-cpp CONFIG REQUIRED)\r\ntarget_link_libraries(&lt;your project name&gt; PRIVATE Azure::azure-storage-blobs)\r\n\r\nfind_package(azure-storage-files-shares-cpp CONFIG REQUIRED)\r\ntarget_link_libraries(&lt;your project name&gt; PRIVATE Azure::azure-storage-files-shares)\r\n\r\nfind_package(azure-storage-datalake-cpp CONFIG REQUIRED)\r\ntarget_link_libraries(&lt;your project name&gt; PRIVATE Azure::azure-storage-datalake)<\/code><\/pre>\n<h3>Listing blobs in a container<\/h3>\n<p>The following snippet creates a <code>BlobContainerClient<\/code>, which connects with the Azure Storage service, and then lists the blobs in a container using the <code>containerClient<\/code> object. Note that in this snippet, the connection string is a secret that has been stored in an environment variable and should not be shared.<\/p>\n<pre><code class=\"language-cpp\">#include &lt;azure\/storage\/blobs.cpp&gt;\r\nusing namespace Azure::Storage::Blobs;\r\n\r\nstd::string connectionString = std::get_env(\"AZURE_STORAGE_CONNECTION_STRING\");\r\nstd::string containerName = \"mycontainer\";\r\n\r\nBlobContainerClient containerClient = BlobContainerClient::CreateFromConnectionString(connectionString, containerName);\r\n\r\nauto listBlobsResponse = containerClient.ListBlobs();\r\n\r\nfor (auto blobItem : listBlobsResponse.Blobs)\r\n{\r\n    std::cout &lt;&lt; \"Blob name: \" &lt;&lt; blobItem.Name &lt;&lt; std::endl;\r\n}<\/code><\/pre>\n<h3>Uploading a file to an Azure Files Share<\/h3>\n<p>To upload a file to the files share, we create a <code>ShareClient<\/code>, which connects with the Azure Storage service, and then a <code>ShareFileClient<\/code> to upload the file contents. Note again, in this snippet the connection string has been stored in an environment variable.<\/p>\n<pre><code class=\"language-cpp\">#include &lt;azure\/storage\/files\/shares.hpp&gt;\r\nusing namespace Azure::Storage::Files::Shares;\r\n\r\nstd::string connectionString = std::get_env(\"AZURE_STORAGE_CONNECTION_STRING\");\r\nstd::string shareName = \"myshare\";\r\nstd::string fileName = \"myfile\";\r\nstd::string fileContent = \"Hello Azure!\";\r\n\r\nauto shareClient = ShareClient::CreateFromConnectionString(connectionString, shareName);\r\nshareClient.CreateIfNotExists();\r\n\r\nShareFileClient fileClient = shareClient.GetRootDirectoryClient().GetFileClient(fileName);\r\nfileClient.UploadFrom(reinterpret_cast&lt;const uint8_t*&gt;(fileContent.data()), fileContent.size());<\/code><\/pre>\n<h2>More Samples<\/h2>\n<p>To see a full scenario for the Azure SDKs for C++, visit the official <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\">Azure SDK for C++<\/a> repository or go to <a href=\"https:\/\/docs.microsoft.com\/cpp\">Microsoft Docs<\/a>. To get you started quickly, you can visit the following quickstarts and samples:<\/p>\n<table>\n<thead>\n<tr>\n<th>SDK<\/th>\n<th style=\"text-align: left;\">Quickstart on Docs<\/th>\n<th style=\"text-align: right;\">Samples on GitHub<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>azure-storage-blobs-cpp<\/td>\n<td style=\"text-align: left;\"><a href=\"https:\/\/docs.microsoft.com\/azure\/storage\/blobs\/quickstart-blobs-c-plus-plus\">Quickstart<\/a><\/td>\n<td style=\"text-align: right;\"><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\/tree\/master\/sdk\/storage\/azure-storage-blobs\/sample\">GitHub<\/a><\/td>\n<\/tr>\n<tr>\n<td>azure-storage-files-shares-cpp<\/td>\n<td style=\"text-align: left;\"><a href=\"https:\/\/docs.microsoft.com\/azure\/storage\/files\/storage-c-plus-plus-how-to-use-files\">QuickStart<\/a><\/td>\n<td style=\"text-align: right;\"><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\/tree\/master\/sdk\/storage\/azure-storage-files-shares\/sample\">GitHub<\/a><\/td>\n<\/tr>\n<tr>\n<td>azure-storage-files-datalake-cpp<\/td>\n<td style=\"text-align: left;\">&#8211;<\/td>\n<td style=\"text-align: right;\"><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\/tree\/master\/sdk\/storage\/azure-storage-files-datalake\/sample\">GitHub<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Consistent and Idiomatic<\/h2>\n<p>Developers familiar with our other Azure Storage libraries might notice the recurrence of the Azure::Storage::Blobs::BlobContainerClient or Azure::Storage::Files::Shares::ShareClient classes. In accordance with our <a href=\"https:\/\/azure.github.io\/azure-sdk\/general_introduction.html\">General Guidelines<\/a>, we aim for a developer experience that is both consistent with the Azure Storage libraries for our <a href=\"https:\/\/aka.ms\/azsdk\">currently released libraries<\/a> as well as idiomatic to the C++ standards so that developers are supported regardless of the programming language.<\/p>\n<h2>Support, Feedback, Feature Requests, and Bug Reporting<\/h2>\n<p>The easiest way to get in touch with our development team is to open an issue on the official <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-cpp\">Azure SDK for C++<\/a> repository. We regularly triage new issues; for more information about our GitHub process, check out Lily Ma&#8217;s blog post <a href=\"https:\/\/devblogs.microsoft.com\/azure-sdk\/github-issue-support-process\/\">Azure SDK GitHub Support Process<\/a>.<\/p>\n<p><!-- TIPS: - Use `SDK` when talking about all of the client libraries. - Use `Client libraries\/ry` when talking about individual libraries. - Make sure all links do not have Locale, i.e remove `en-us` from all links. - All image links need to start with `.\/images\/posts\/*.png` and need to match exact case of the file. - Avoid using `here` for link text. Use the title of the link\/file. - Please include summary at the end. --><\/p>\n<p><!-- FOOTER: DO NOT EDIT OR REMOVE --><\/p>\n<p><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=\"mailto:azsdkblog@microsoft.com\">azsdkblog@microsoft.com<\/a> with your topic and we&#8217;ll get you set up 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>The Azure SDK team is thrilled to introduce Azure Core, Identity, and Storage Blobs, Files Shares, Datalake for C++. This post details some of the recent improvements, samples, and getting started guides available to you, the developer.<\/p>\n","protected":false},"author":42386,"featured_media":1269,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[815,24,738],"class_list":["post-1277","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-c","tag-releases","tag-storage"],"acf":[],"blog_post_summary":"<p>The Azure SDK team is thrilled to introduce Azure Core, Identity, and Storage Blobs, Files Shares, Datalake for C++. This post details some of the recent improvements, samples, and getting started guides available to you, the developer.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/1277","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\/42386"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=1277"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/1277\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/1269"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=1277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=1277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=1277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}