| 449 | } |
| 450 | |
| 451 | Result<std::unique_ptr<DataLake::DataLakeServiceClient>> |
| 452 | AzureOptions::MakeDataLakeServiceClient() const { |
| 453 | if (account_name.empty()) { |
| 454 | return Status::Invalid("AzureOptions doesn't contain a valid account name"); |
| 455 | } |
| 456 | if (!(dfs_storage_scheme == "http" || dfs_storage_scheme == "https")) { |
| 457 | return Status::Invalid("AzureOptions::dfs_storage_scheme must be http or https: ", |
| 458 | dfs_storage_scheme); |
| 459 | } |
| 460 | DataLake::DataLakeClientOptions client_options; |
| 461 | client_options.Telemetry.ApplicationId = BuildApplicationId(); |
| 462 | switch (credential_kind_) { |
| 463 | case CredentialKind::kAnonymous: |
| 464 | return std::make_unique<DataLake::DataLakeServiceClient>( |
| 465 | AccountDfsUrl(account_name), client_options); |
| 466 | case CredentialKind::kDefault: |
| 467 | if (!token_credential_) { |
| 468 | token_credential_ = std::make_shared<Azure::Identity::DefaultAzureCredential>(); |
| 469 | } |
| 470 | [[fallthrough]]; |
| 471 | case CredentialKind::kClientSecret: |
| 472 | case CredentialKind::kManagedIdentity: |
| 473 | case CredentialKind::kCLI: |
| 474 | case CredentialKind::kWorkloadIdentity: |
| 475 | case CredentialKind::kEnvironment: |
| 476 | return std::make_unique<DataLake::DataLakeServiceClient>( |
| 477 | AccountDfsUrl(account_name), token_credential_, client_options); |
| 478 | case CredentialKind::kStorageSharedKey: |
| 479 | return std::make_unique<DataLake::DataLakeServiceClient>( |
| 480 | AccountDfsUrl(account_name), storage_shared_key_credential_, client_options); |
| 481 | case CredentialKind::kSASToken: |
| 482 | return std::make_unique<DataLake::DataLakeServiceClient>( |
| 483 | AccountBlobUrl(account_name) + sas_token_, client_options); |
| 484 | } |
| 485 | return Status::Invalid("AzureOptions doesn't contain a valid auth configuration"); |
| 486 | } |
| 487 | |
| 488 | namespace { |
| 489 | |