diff --git a/pkg/storage/bucket/azure/bucket_client.go b/pkg/storage/bucket/azure/bucket_client.go index e6df3721a3ded..53112302de76a 100644 --- a/pkg/storage/bucket/azure/bucket_client.go +++ b/pkg/storage/bucket/azure/bucket_client.go @@ -12,10 +12,14 @@ func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucke bucketConfig := azure.Config{ StorageAccountName: cfg.StorageAccountName, StorageAccountKey: cfg.StorageAccountKey.String(), - StorageConnectionString: cfg.ConnectionString.String(), + StorageConnectionString: cfg.StorageConnectionString.String(), ContainerName: cfg.ContainerName, Endpoint: cfg.EndpointSuffix, MaxRetries: cfg.MaxRetries, + UserAssignedID: cfg.UserAssignedID, + PipelineConfig: azure.PipelineConfig{ + MaxRetryDelay: model.Duration(cfg.MaxRetryDelay), + }, HTTPConfig: azure.HTTPConfig{ IdleConnTimeout: model.Duration(cfg.HTTP.IdleConnTimeout), ResponseHeaderTimeout: model.Duration(cfg.HTTP.ResponseHeaderTimeout), diff --git a/pkg/storage/bucket/azure/config.go b/pkg/storage/bucket/azure/config.go index 47027c86c82fd..57d90f708f426 100644 --- a/pkg/storage/bucket/azure/config.go +++ b/pkg/storage/bucket/azure/config.go @@ -2,6 +2,7 @@ package azure import ( "flag" + "time" "net/http" @@ -19,12 +20,14 @@ type HTTPConfig struct { // Config holds the config options for an Azure backend type Config struct { - StorageAccountName string `yaml:"account_name"` - StorageAccountKey flagext.Secret `yaml:"account_key"` - ConnectionString flagext.Secret `yaml:"connection_string"` - ContainerName string `yaml:"container_name"` - EndpointSuffix string `yaml:"endpoint_suffix"` - MaxRetries int `yaml:"max_retries"` + StorageAccountName string `yaml:"account_name"` + StorageAccountKey flagext.Secret `yaml:"account_key"` + StorageConnectionString flagext.Secret `yaml:"connection_string"` + ContainerName string `yaml:"container_name"` + EndpointSuffix string `yaml:"endpoint_suffix"` + UserAssignedID string `yaml:"user_assigned_id"` + MaxRetries int `yaml:"max_retries"` + MaxRetryDelay time.Duration `yaml:"max_retry_delay"` HTTP HTTPConfig `yaml:"http"` } @@ -38,9 +41,11 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { f.StringVar(&cfg.StorageAccountName, prefix+"azure.account-name", "", "Azure storage account name") f.Var(&cfg.StorageAccountKey, prefix+"azure.account-key", "Azure storage account key") - f.Var(&cfg.ConnectionString, prefix+"azure.connection-string", "If `connection-string` is set, the values of `account-name` and `endpoint-suffix` values will not be used. Use this method over `account-key` if you need to authenticate via a SAS token. Or if you use the Azurite emulator.") + f.Var(&cfg.StorageConnectionString, prefix+"azure.connection-string", "If `connection-string` is set, the values of `account-name` and `endpoint-suffix` values will not be used. Use this method over `account-key` if you need to authenticate via a SAS token. Or if you use the Azurite emulator.") f.StringVar(&cfg.ContainerName, prefix+"azure.container-name", "loki", "Azure storage container name") f.StringVar(&cfg.EndpointSuffix, prefix+"azure.endpoint-suffix", "", "Azure storage endpoint suffix without schema. The account name will be prefixed to this value to create the FQDN") + f.StringVar(&cfg.UserAssignedID, prefix+"azure.user-assigned-id", "", "User assigned identity ID to authenticate to the Azure storage account.") f.IntVar(&cfg.MaxRetries, prefix+"azure.max-retries", 20, "Number of retries for recoverable errors") + f.DurationVar(&cfg.MaxRetryDelay, prefix+"azure.max-retry-delay", 500*time.Millisecond, "Maximum time to wait before retrying a request.") cfg.HTTP.RegisterFlagsWithPrefix(prefix+"azure.http", f) } diff --git a/pkg/storage/bucket/azure/config_test.go b/pkg/storage/bucket/azure/config_test.go index c5486ceb15066..8d9d2e87910d6 100644 --- a/pkg/storage/bucket/azure/config_test.go +++ b/pkg/storage/bucket/azure/config_test.go @@ -61,12 +61,12 @@ http: max_connections_per_host: 8 `, expectedConfig: Config{ - StorageAccountName: "test-account-name", - StorageAccountKey: flagext.SecretWithValue("test-account-key"), - ConnectionString: flagext.SecretWithValue("test-connection-string"), - ContainerName: "test-container-name", - EndpointSuffix: "test-endpoint-suffix", - MaxRetries: 1, + StorageAccountName: "test-account-name", + StorageAccountKey: flagext.SecretWithValue("test-account-key"), + StorageConnectionString: flagext.SecretWithValue("test-connection-string"), + ContainerName: "test-container-name", + EndpointSuffix: "test-endpoint-suffix", + MaxRetries: 1, HTTP: HTTPConfig{ Config: http.Config{ IdleConnTimeout: 2 * time.Second,