| 412 | } |
| 413 | |
| 414 | Result<std::unique_ptr<Blobs::BlobServiceClient>> AzureOptions::MakeBlobServiceClient() |
| 415 | const { |
| 416 | if (account_name.empty()) { |
| 417 | return Status::Invalid("AzureOptions doesn't contain a valid account name"); |
| 418 | } |
| 419 | if (!(blob_storage_scheme == "http" || blob_storage_scheme == "https")) { |
| 420 | return Status::Invalid("AzureOptions::blob_storage_scheme must be http or https: ", |
| 421 | blob_storage_scheme); |
| 422 | } |
| 423 | Blobs::BlobClientOptions client_options; |
| 424 | client_options.Telemetry.ApplicationId = BuildApplicationId(); |
| 425 | switch (credential_kind_) { |
| 426 | case CredentialKind::kAnonymous: |
| 427 | return std::make_unique<Blobs::BlobServiceClient>(AccountBlobUrl(account_name), |
| 428 | client_options); |
| 429 | case CredentialKind::kDefault: |
| 430 | if (!token_credential_) { |
| 431 | token_credential_ = std::make_shared<Azure::Identity::DefaultAzureCredential>(); |
| 432 | } |
| 433 | [[fallthrough]]; |
| 434 | case CredentialKind::kClientSecret: |
| 435 | case CredentialKind::kManagedIdentity: |
| 436 | case CredentialKind::kCLI: |
| 437 | case CredentialKind::kWorkloadIdentity: |
| 438 | case CredentialKind::kEnvironment: |
| 439 | return std::make_unique<Blobs::BlobServiceClient>( |
| 440 | AccountBlobUrl(account_name), token_credential_, client_options); |
| 441 | case CredentialKind::kStorageSharedKey: |
| 442 | return std::make_unique<Blobs::BlobServiceClient>( |
| 443 | AccountBlobUrl(account_name), storage_shared_key_credential_, client_options); |
| 444 | case CredentialKind::kSASToken: |
| 445 | return std::make_unique<Blobs::BlobServiceClient>( |
| 446 | AccountBlobUrl(account_name) + sas_token_, client_options); |
| 447 | } |
| 448 | return Status::Invalid("AzureOptions doesn't contain a valid auth configuration"); |
| 449 | } |
| 450 | |
| 451 | Result<std::unique_ptr<DataLake::DataLakeServiceClient>> |
| 452 | AzureOptions::MakeDataLakeServiceClient() const { |