Code Monkey home page Code Monkey logo

duochen / azure-sdk-for-cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure/azure-sdk-for-cpp

0.0 1.0 0.0 8.08 MB

This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our versioned developer docs at https://azure.github.io/azure-sdk-for-cpp.

License: MIT License

CMake 1.97% C++ 90.15% PowerShell 6.42% HTML 0.44% Batchfile 0.03% CSS 0.78% JavaScript 0.17% Dockerfile 0.05%

azure-sdk-for-cpp's Introduction

Azure SDK for C++

Build Status

This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our developer docs.

Getting started

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.

Download & Install the SDK

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.

Building your Application

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

Visual Studio - CMakeSettings.json

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"
        }
      ]
    }
  ]
}

Azure Requirements

To call Azure services, you must first have an Azure subscription. Sign up for a free trial or use your MSDN subscriber benefits.

Packages available

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.

Vcpkg

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.

Need help

Navigating the repository

Master branch

The master branch has the most recent code with new features and bug fixes. It does not represent latest released beta or GA SDK.

Release branches (Release tagging)

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.

Contributing

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.

Additional Helpful Links for Contributors

Many people all over the world have helped make this project better. You'll want to check out:

Reporting security issues and security bugs

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.

License

Azure SDK for C++ is licensed under the MIT license.

Impressions

azure-sdk-for-cpp's People

Contributors

azure-sdk avatar jinming-hu avatar vhvb1989 avatar katmsft avatar antkmsft avatar ahsonkhan avatar rickwinter avatar danieljurek avatar chidozieononiwu avatar sima-zhu avatar mitchdenny avatar damirault avatar microsoftopensource avatar ku-sourav avatar caseycarter avatar lordgamez avatar joshfree avatar sjoubert avatar billyoneal avatar jasonyang-msft avatar jeffreyrichter avatar karishmaghiya avatar juchem avatar animeshdas2000 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.