Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ if(NOT TRITON_CORE_HEADERS_ONLY)
-Dazure-storage-blobs-cpp_DIR:PATH=${TRITON_THIRD_PARTY_INSTALL_PREFIX}/azure-sdk/share/azure-storage-blobs-cpp
-Dazure-storage-common-cpp_DIR:PATH=${TRITON_THIRD_PARTY_INSTALL_PREFIX}/azure-sdk/share/azure-storage-common-cpp
-Dazure-core-cpp_DIR:PATH=${TRITON_THIRD_PARTY_INSTALL_PREFIX}/azure-sdk/share/azure-core-cpp
-Dazure-identity-cpp_DIR:PATH=${TRITON_THIRD_PARTY_INSTALL_PREFIX}/azure-sdk/share/azure-identity-cpp
)
endif() # TRITON_ENABLE_AZURE_STORAGE
if(${TRITON_ENABLE_METRICS})
Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ endif()
if(${TRITON_ENABLE_AZURE_STORAGE})
find_package(azure-storage-blobs-cpp CONFIG REQUIRED)
message(STATUS "Using Azure storage blobs ${azure-storage-blobs-cpp_VERSION}")
find_package(azure-identity-cpp CONFIG REQUIRED)
message(STATUS "Using Azure identity ${azure-identity-cpp_VERSION}")
endif()

configure_file(libtritonserver.ldscript libtritonserver.ldscript COPYONLY)
Expand Down Expand Up @@ -327,6 +329,7 @@ if(${TRITON_ENABLE_AZURE_STORAGE})
target_include_directories(
triton-core
PRIVATE $<TARGET_PROPERTY:Azure::azure-storage-blobs,INTERFACE_INCLUDE_DIRECTORIES>
PRIVATE $<TARGET_PROPERTY:Azure::azure-identity,INTERFACE_INCLUDE_DIRECTORIES>
)
endif() # TRITON_ENABLE_AZURE_STORAGE

Expand Down Expand Up @@ -501,6 +504,11 @@ if(${TRITON_ENABLE_AZURE_STORAGE})
PRIVATE
Azure::azure-storage-blobs
)
target_link_libraries(
triton-core
PRIVATE
Azure::azure-identity
)
endif() # TRITON_ENABLE_AZURE_STORAGE

if(${TRITON_ENABLE_GPU})
Expand Down
9 changes: 9 additions & 0 deletions src/filesystem/implementations/as.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once

#include <azure/identity.hpp>
#include <azure/storage/blobs.hpp>
#include <azure/storage/common/storage_credential.hpp>

Expand All @@ -37,6 +38,7 @@ namespace triton { namespace core {

namespace as = Azure::Storage;
namespace asb = Azure::Storage::Blobs;
namespace ai = Azure::Identity;
const std::string AS_URL_PATTERN = "as://([^/]+)/([^/?]+)(?:/([^?]*))?(\\?.*)?";

struct ASCredential {
Expand Down Expand Up @@ -152,11 +154,18 @@ ASFileSystem::ASFileSystem(const std::string& path, const ASCredential& as_cred)
std::string service_url(
"https://" + account_name + ".blob.core.windows.net");

auto use_default_env =
GetEnvironmentVariableOrDefault("AZURE_USE_DEFAULT_CREDENTIAL", "0");

if (!as_cred.account_key_.empty()) {
// Shared Key
auto cred = std::make_shared<as::StorageSharedKeyCredential>(
account_name, as_cred.account_key_);
client_ = std::make_shared<asb::BlobServiceClient>(service_url, cred);
} else if (use_default_env == "1" || use_default_env == "true") {
// Default Azure Credential (Managed Identity, Environment, VS, CLI, etc)
auto cred = std::make_shared<ai::DefaultAzureCredential>();
client_ = std::make_shared<asb::BlobServiceClient>(service_url, cred);
} else {
client_ = std::make_shared<asb::BlobServiceClient>(service_url);
}
Expand Down