From aead27eceef8d9637710eeb889b92b1abdab89a3 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 | 12 ++++++++++-- libs/remote_storage/src/config.rs | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/remote_storage/src/azure_blob.rs b/libs/remote_storage/src/azure_blob.rs index 345f559798..4664d72cbe 100644 --- a/libs/remote_storage/src/azure_blob.rs +++ b/libs/remote_storage/src/azure_blob.rs @@ -19,6 +19,7 @@ use azure_core::HttpClient; use azure_core::TransportOptions; 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; @@ -72,8 +73,15 @@ impl AzureBlobStorage { StorageCredentials::token_credential(Arc::new(token_credential)) }; - // we have an outer retry - let builder = ClientBuilder::new(account, credentials) + 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()) .transport(TransportOptions::new(reqwest_client(true))); diff --git a/libs/remote_storage/src/config.rs b/libs/remote_storage/src/config.rs index e99ae4f747..da49902f76 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, }),