Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring the endpoint for Azure #9876

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
13 changes: 11 additions & 2 deletions libs/remote_storage/src/azure_blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,8 +73,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());

Expand Down
4 changes: 4 additions & 0 deletions libs/remote_storage/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// The endpoint to use. Use the default if None.
pub endpoint: Option<String>,
/// 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")]
Expand All @@ -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",
Expand Down Expand Up @@ -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,
}),
Expand Down
Loading