Skip to content

Commit df50749

Browse files
authored
feat: support Azure ClientSecretCredential authentication (#4477)
* feat: support Azure ClientSecretCredential * fix: consistent naming and descriptions for Azure client sercet values * fix: ordering of azure storage options
1 parent 8d39c53 commit df50749

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

cmd/pyroscope/help-all.txt.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,12 @@ Usage of ./pyroscope:
917917
Azure storage account key. If unset, Azure managed identities will be used for authentication instead.
918918
-storage.azure.account-name string
919919
Azure storage account name
920+
-storage.azure.az-tenant-id string
921+
Azure Active Directory tenant ID. If set alongside `client-id` and `client-secret`, these values will be used for authentication via a client secret credential.
922+
-storage.azure.client-id string
923+
Azure Active Directory client ID. If set alongside `az-tenant-id` and `client-secret`, these values will be used for authentication via a client secret credential.
924+
-storage.azure.client-secret string
925+
Azure Active Directory client secret. If set alongside `az-tenant-id` and `client-id`, these values will be used for authentication via a client secret credential.
920926
-storage.azure.connection-string string
921927
If `connection-string` is set, the value of `endpoint-suffix` 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.
922928
-storage.azure.container-name string

cmd/pyroscope/help.txt.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ Usage of ./pyroscope:
313313
Azure storage account key. If unset, Azure managed identities will be used for authentication instead.
314314
-storage.azure.account-name string
315315
Azure storage account name
316+
-storage.azure.az-tenant-id string
317+
Azure Active Directory tenant ID. If set alongside `client-id` and `client-secret`, these values will be used for authentication via a client secret credential.
318+
-storage.azure.client-id string
319+
Azure Active Directory client ID. If set alongside `az-tenant-id` and `client-secret`, these values will be used for authentication via a client secret credential.
320+
-storage.azure.client-secret string
321+
Azure Active Directory client secret. If set alongside `az-tenant-id` and `client-id`, these values will be used for authentication via a client secret credential.
316322
-storage.azure.connection-string string
317323
If `connection-string` is set, the value of `endpoint-suffix` 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.
318324
-storage.azure.container-name string

docs/sources/configure-server/reference-configuration-parameters/index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,6 +2548,24 @@ http:
25482548
The `azure_storage_backend` block configures the connection to Azure object storage backend.
25492549

25502550
```yaml
2551+
# Azure Active Directory tenant ID. If set alongside `client-id` and
2552+
# `client-secret`, these values will be used for authentication via a client
2553+
# secret credential.
2554+
# CLI flag: -storage.azure.az-tenant-id
2555+
[az_tenant_id: <string> | default = ""]
2556+
2557+
# Azure Active Directory client ID. If set alongside `az-tenant-id` and
2558+
# `client-secret`, these values will be used for authentication via a client
2559+
# secret credential.
2560+
# CLI flag: -storage.azure.client-id
2561+
[client_id: <string> | default = ""]
2562+
2563+
# Azure Active Directory client secret. If set alongside `az-tenant-id` and
2564+
# `client-id`, these values will be used for authentication via a client secret
2565+
# credential.
2566+
# CLI flag: -storage.azure.client-secret
2567+
[client_secret: <string> | default = ""]
2568+
25512569
# Azure storage account name
25522570
# CLI flag: -storage.azure.account-name
25532571
[account_name: <string> | default = ""]

pkg/objstore/providers/azure/bucket_client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ func newBucketClient(cfg Config, name string, logger log.Logger, factory func(lo
2121
// Start with default config to make sure that all parameters are set to sensible values, especially
2222
// HTTP Config field.
2323
bucketConfig := azure.DefaultConfig
24+
bucketConfig.AzTenantID = cfg.AzTenantID
25+
bucketConfig.ClientID = cfg.ClientID
26+
bucketConfig.ClientSecret = cfg.ClientSecret.String()
2427
bucketConfig.StorageAccountName = cfg.StorageAccountName
2528
bucketConfig.StorageAccountKey = cfg.StorageAccountKey.String()
2629
bucketConfig.StorageConnectionString = cfg.StorageConnectionString.String()

pkg/objstore/providers/azure/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import (
1313

1414
// Config holds the config options for an Azure backend
1515
type Config struct {
16+
AzTenantID string `yaml:"az_tenant_id"`
17+
ClientID string `yaml:"client_id"`
18+
ClientSecret flagext.Secret `yaml:"client_secret"`
1619
StorageAccountName string `yaml:"account_name"`
1720
StorageAccountKey flagext.Secret `yaml:"account_key"`
1821
StorageConnectionString flagext.Secret `yaml:"connection_string"`
@@ -29,6 +32,9 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
2932

3033
// RegisterFlagsWithPrefix registers the flags for Azure storage
3134
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
35+
f.StringVar(&cfg.AzTenantID, prefix+"azure.az-tenant-id", "", "Azure Active Directory tenant ID. If set alongside `client-id` and `client-secret`, these values will be used for authentication via a client secret credential.")
36+
f.StringVar(&cfg.ClientID, prefix+"azure.client-id", "", "Azure Active Directory client ID. If set alongside `az-tenant-id` and `client-secret`, these values will be used for authentication via a client secret credential.")
37+
f.Var(&cfg.ClientSecret, prefix+"azure.client-secret", "Azure Active Directory client secret. If set alongside `az-tenant-id` and `client-id`, these values will be used for authentication via a client secret credential.")
3238
f.StringVar(&cfg.StorageAccountName, prefix+"azure.account-name", "", "Azure storage account name")
3339
f.Var(&cfg.StorageAccountKey, prefix+"azure.account-key", "Azure storage account key. If unset, Azure managed identities will be used for authentication instead.")
3440
f.Var(&cfg.StorageConnectionString, prefix+"azure.connection-string", "If `connection-string` is set, the value of `endpoint-suffix` 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.")

0 commit comments

Comments
 (0)