This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our developer docs.
For the best development experience, we recommend developers use CMake projects in Visual Studio to view and build the source code together with its dependencies. You can also use any other text editor of your choice, such as VS Code, along with the command line for building your application with the SDK.
You can find additional information for specific libraries by navigating to the appropriate folder in the /sdk
directory. See the README.md file located in the library's project folder, for example, the Azure Storage client library.
For API reference docs, tutorials, samples, quick starts, and other documentation, go to Azure SDK for C++ Developer Docs.
The easiest way to acquire the C++ SDK is leveraging vcpkg package manager. You will need to install Git before getting started.
First clone and bootstrap vcpkg itself. You can install it anywhere on your machine, but make note of the directory where you clone the vcpkg repo.
> git clone https://github.com/microsoft/vcpkg
On Windows:
> .\vcpkg\bootstrap-vcpkg.bat
On Linux:
> ./vcpkg/bootstrap-vcpkg.sh
To install the libraries for your project, run the following, optionally specifying the triplet. For example, the following will install packages for the x64-windows
triplet. On Windows, not specifying a triplet will default to x86-windows
:
> .\vcpkg\vcpkg install azure-storage-blobs-cpp:x64-windows
See the list of packages available via vcpkg below. All Azure C++ SDK package names start with azure-
. You can also search for the libraries you need with the search
command. For example:
> .\vcpkg\vcpkg search azure-
Once the library is installed, follow the instructions from the console output to include the library in your CMake
application. For example, to include azure-storage-blobs-cpp
, add the following to your CMakeLists.txt
file:
find_package(azure-storage-blobs-cpp CONFIG REQUIRED)
target_link_libraries(<your project name> PRIVATE Azure::azure-storage-blobs)
NOTE: All the Azure client libraries take a dependency on
azure-core-cpp
which provides functionality commonly needed by all Azure clients. When you install any client library via vcpkg, it will bring in all the necessary dependencies as well. You don't need to install those individually to get started.
You can reference this vcpkg Quick Start for more details.
In order to use the SDK installed via vcpkg with CMake, you can use the toolchain file from vcpkg:
> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg repo]/scripts/buildsystems/vcpkg.cmake
> cmake --build [build directory]
The entry point for most scenarios when using the SDK will be a top-level client type corresponding to the Azure service you want to talk to. For example, sending requests to blob storage can be done via the Azure::Storage::Blobs::BlobClient
API.
All the Azure C++ SDK headers needed to be included are located within the <azure>
folder, with sub-folders corresponding to each service. Similarly, all types and APIs can be found within the Azure::
namespace. For example, to use functionality form Azure::Core
, include the following header at the beginning of your application #include <azure/core.hpp>
.
Here's an example application to help you get started:
#include <iostream>
#include <azure/core.hpp>
#include <azure/storage/blobs.hpp>
using namespace Azure::Storage::Blobs;
// Get the required connection string/key from an environment variable or Azure KeyVault.
std::string GetConnectionString();
int main()
{
std::string containerName = "testcontainer";
std::string blobName = "sample-blob";
try
{
auto client = BlobClient::CreateFromConnectionString(
GetConnectionString(), containerName, blobName);
}
catch (const Azure::Core::RequestFailedException& e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
Understanding the key concepts from the azure-core-cpp
library, which is leveraged by all client libraries will also be helpful in getting started, regardless of which Azure service you want to use. You can find more information about them, with sample code snippets, here: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/core/azure-core#key-concepts
When building your application via Visual Studio, you can create and update a CMakeSettings.json
file and include the following properties to let Visual Studio know where the packages are installed and which triplet needs to be used:
{
"configurations": [
{
"cmakeToolchain": "<path to vcpkg repo>/vcpkg/scripts/buildsystems/vcpkg.cmake",
"variables": [
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "x64-windows",
"type": "STRING"
}
]
}
]
}
To call Azure services, you must first have an Azure subscription. Sign up for a free trial or use your MSDN subscriber benefits.
Each service might have a number of libraries available. These libraries follow the Azure SDK Design Guidelines for C++ and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features at Azure::Core.
The client libraries can be identified by the naming used for their folder, package, and namespace. Each will start with azure
, followed by the service category, and then the name of the service. For example azure-storage-blobs
.
For a complete list of available packages, please see the latest available packages page.
NOTE: If you need to ensure your code is ready for production we strongly recommend using one of the stable, non-beta libraries.
The following SDK library releases are available on vcpkg:
azure-core-cpp
azure-identity-cpp
azure-storage-blobs-cpp
azure-storage-common-cpp
azure-storage-files-datalake-cpp
azure-storage-files-shares-cpp
NOTE: In case of getting linker errors when consuming the SDK on Windows, make sure that vcpkg triplet being consumed matches the CRT link flags being set for your app or library build. See also
MSVC_USE_STATIC_CRT
build flag.
- For reference documentation visit the Azure SDK for C++ documentation.
- For tutorials, samples, quick starts and other documentation, visit Azure for C++ Developers.
- File an issue via Github Issues.
The master branch has the most recent code with new features and bug fixes. It does not represent latest released beta or GA SDK.
For each package we release there will be a unique git tag created that contains the name and the version of the package to mark the commit of the code that produced the package. This tag will be used for servicing via hotfix branches as well as debugging the code for a particular beta or stable release version.
Format of the release tags are <package-name>_<package-version>
. For more information please see our branching strategy.
For details on contributing to this repository, see the contributing guide.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, view Microsoft's CLA.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
Many people all over the world have helped make this project better. You'll want to check out:
- What are some good first issues for new contributors to the repo?
- How to build and test your change
- How you can make a change happen!
- Frequently Asked Questions (FAQ) and Conceptual Topics in the detailed Azure SDK for C++ wiki.
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.
Azure SDK for C++ is licensed under the MIT license.