lib_azure: test case

This commit is contained in:
Minglei Jin 2024-10-10 08:58:02 +08:00
parent 3890def22b
commit c6018cbfaa
2 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,29 @@
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_executable (
azure-test
main.cpp
)
# Link to Azure SDK
#target_link_libraries(application _azure_sdk)
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
find_library(XML2_LIBRARY xml2 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
#find_library(XML2_LIBRARY xml2)
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
#find_library(CoreFoundation_Library CoreFoundation)
#find_library(SystemConfiguration_Library SystemConfiguration)
target_link_libraries(
azure-test
PRIVATE _azure_sdk
PRIVATE ${CURL_LIBRARY}
PRIVATE ${XML2_LIBRARY}
PRIVATE ${SSL_LIBRARY}
PRIVATE ${CRYPTO_LIBRARY}
PRIVATE dl
PRIVATE pthread
)

View File

@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @file
* @brief Application that consumes the Azure SDK for C++.
*
* @remark Set environment variable `STORAGE_CONNECTION_STRING` before running the application.
*
*/
#include <azure/storage/blobs.hpp>
#include <exception>
#include <iostream>
using namespace Azure::Storage::Blobs;
int main(int argc, char* argv[])
{
(void)argc;
(void)argv;
/**************** Container SDK client ************************/
/**************** Create container ************************/
try
{
auto containerClient = BlobContainerClient::CreateFromConnectionString(
std::getenv("STORAGE_CONNECTION_STRING"), "td-test");
//containerClient.CreateIfNotExists();
/**************** Container SDK client ************************/
/**************** list blobs (one page) ******************/
//auto response = containerClient.ListBlobsSinglePage();
//auto response = containerClient.ListBlobs();
//auto blobListPage = response.Value;
//auto blobListPage = response.Blobs;
for (auto page = containerClient.ListBlobs(/*options*/); page.HasPage(); page.MoveToNextPage())
{
for (auto& blob : page.Blobs)
{
std::cout << blob.Name << std::endl;
}
}
}
catch (const std::exception& ex)
{
std::cout << ex.what();
return 1;
}
return 0;
}