From bb839903f847ca6a38cc0c4cede50def8d61cdf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arpad=20M=C3=BCller?= Date: Mon, 25 Nov 2024 12:47:08 +0100 Subject: [PATCH] Allow configuring the endpoint for Azure --- libs/remote_storage/src/azure_blob.rs | 13 +++++++++++-- libs/remote_storage/src/config.rs | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/remote_storage/src/azure_blob.rs b/libs/remote_storage/src/azure_blob.rs index 1c0d43d479a1..ed56bdcc7006 100644 --- a/libs/remote_storage/src/azure_blob.rs +++ b/libs/remote_storage/src/azure_blob.rs @@ -17,6 +17,7 @@ use anyhow::Result; use azure_core::request_options::{IfMatchCondition, MaxResults, Metadata, Range}; use azure_core::{Continuable, RetryOptions}; use azure_identity::DefaultAzureCredential; +use azure_storage::CloudLocation; use azure_storage::StorageCredentials; use azure_storage_blobs::blob::CopyStatus; use azure_storage_blobs::prelude::ClientBuilder; @@ -70,8 +71,16 @@ impl AzureBlobStorage { StorageCredentials::token_credential(Arc::new(token_credential)) }; - // we have an outer retry - let builder = ClientBuilder::new(account, credentials).retry(RetryOptions::none()); + let location = match &azure_config.endpoint { + None => CloudLocation::Public { account }, + Some(endpoint) => CloudLocation::Custom { + account, + uri: endpoint.clone(), + }, + }; + let builder = ClientBuilder::with_location(location, credentials) + // we have an outer retry + .retry(RetryOptions::none()); let client = builder.container_client(azure_config.container_name.to_owned()); diff --git a/libs/remote_storage/src/config.rs b/libs/remote_storage/src/config.rs index e99ae4f747d9..da49902f7660 100644 --- a/libs/remote_storage/src/config.rs +++ b/libs/remote_storage/src/config.rs @@ -125,6 +125,8 @@ pub struct AzureConfig { pub container_region: String, /// A "subfolder" in the container, to use the same container separately by multiple remote storage users at once. pub prefix_in_container: Option, + /// The endpoint to use. Use the default if None. + pub endpoint: Option, /// Azure has various limits on its API calls, we need not to exceed those. /// See [`DEFAULT_REMOTE_STORAGE_AZURE_CONCURRENCY_LIMIT`] for more details. #[serde(default = "default_remote_storage_azure_concurrency_limit")] @@ -144,6 +146,7 @@ impl Debug for AzureConfig { .field("storage_account", &self.storage_account) .field("bucket_region", &self.container_region) .field("prefix_in_container", &self.prefix_in_container) + .field("endpoint", &self.endpoint) .field("concurrency_limit", &self.concurrency_limit) .field( "max_keys_per_list_response", @@ -296,6 +299,7 @@ timeout = '5s'"; storage_account: None, container_region: "westeurope".into(), prefix_in_container: None, + endpoint: None, concurrency_limit: default_remote_storage_azure_concurrency_limit(), max_keys_per_list_response: DEFAULT_MAX_KEYS_PER_LIST_RESPONSE, }),