The Azure Storage Client Library (Lite) for C++ allows you to build applications against Microsoft Azure Storage's blob service. This is a minimum dependency version that provide basic object storage. For an overview of Azure Storage, see Introduction to Microsoft Azure Storage. If you want to use other services of Azure Storage, or a more comprehensive functionality of Blob service, please see Azure Storage C++ Client Library.
The full supported Azure Storage API can be found in the following list, please be aware that only part of the functionality of some APIs are supported:
- List Containers.
- Create Container.
- Get Container Properties.
- Delete Container.
- List Blobs.
- Put Blob.
- Get Blob.
- Get Blob Properties.
- Delete Blob.
- Copy Blob.
- Put Block.
- Put Block List.
- Get Block List.
- Put Page.
- Get Page Ranges.
- Append Block.
git clone https://github.com/azure/azure-storage-cpplite.git
sudo apt-get install libssl-dev libcurl4-openssl-dev cmake g++
Or, on Red Hat OS:
sudo yum install openssl-devel.x86_64 libcurl-devel.x86_64 cmake.x86_64 gcc-c++.x86_64
Please be aware that RHEL6 comes with gcc version 4.4.7, which does not meet the requirement of this SDK. In order to use this SDK, devtoolset needs to be installed properly.
cd azure-storage-cpplite
mkdir build.release
cd build.release
CXX=g++ cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_OPENSSL=true
sudo make install
Alternatively, you can use GNUTLS instead of OpenSSL. Simply install GNUTLS and remove the argument -DUSE_OPENSSL
during build.
Simply include the header files after installing the library, everything is good to go. For a more comprehensive sample, please see sample.
To build the sample, add -DBUILD_SAMPLES=true
when building the repository.
#include "storage_credential.h"
#include "storage_account.h"
#include "blob/blob_client.h"
// Your settings
std::string account_name = "YOUR_ACCOUNT_NAME";
std::string account_key = "YOUR_ACCOUNT_KEY";
bool use_https = true;
std::string blob_endpoint = "CUSTOMIZED_BLOB_ENDPOINT";
int connection_count = 2;
// Setup the client
azure::storage_lite::shared_key_credential credential(account_name, account_key);
azure::storage_lite::storage_account(account_name, credential, use_https, blob_endpoint);
azure::storage_lite::blob_client client(storage_account, connection_count);
// Start using
auto outcome = client.create_container("YOUR_CONTAINER_NAME").get();
This project is licensed under MIT.
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, visit https://cla.microsoft.com.
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 repos 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 opencode@microsoft.com with any additional questions or comments.
When contributing to this client library, there are following ground rules:
- All source code change should be clearly addressing issues or adding new features, and should be covered with test.
- Coding style should match with the existing code.
- Any contribution should not degrade performance or complex functionality.
- Introducing new dependency should be done with much great caution. Any new dependency should introduce significant performance improvement or unblock critical user scenario.
Download Catch2 single header version and put it in the folder .\test\catch2\
.
Add -DBUILD_TESTS=true
when building the repository.
Please modify the connection string here to successfully run the tests. All the test uses standard Azure Storage account.
- Project dependencies:
- GNUTLS(or Openssl v7.35.0)
- libcurl v1.0.1
- CMake v2.8.12.2
- g++ v4.8.2
- Dev dependency: catch2.