Skip to content

Commit 9743104

Browse files
authored
[receiver/azureblobreceiver] support for default auth (#35636)
adds "default" auth, to make the azure go package, autodiscover credentials added by e.g. workload identities
1 parent a7579ed commit 9743104

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'enhancement'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: 'azureblobreceiver'
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "adds support for using azidentity default auth, enabling the use of Azure Managed Identities, e.g. Workload Identities on AKS"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35636]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
This change allows to use authentication type "default", which makes the receiver use azidentity default Credentials,
20+
which automatically picks up, identities assigned to e.g. a container or a VirtualMachine
21+
22+
# If your change doesn't affect end users or the exported elements of any package,
23+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
24+
# Optional: The change log or logs in which this entry should be included.
25+
# e.g. '[user]' or '[user, api]'
26+
# Include 'user' if the change is relevant to end users.
27+
# Include 'api' if there is a change to a library API.
28+
# Default: '[user]'
29+
change_logs: []

receiver/azureblobreceiver/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The following settings are required:
2424

2525
The following settings can be optionally configured:
2626

27-
- `auth` (default = connection_string): Specifies the used authentication method. Supported values are `connection_string`, `service_principal`.
27+
- `auth` (default = connection_string): Specifies the used authentication method. Supported values are `connection_string`, `service_principal`, `default`.
2828
- `cloud` (default = "AzureCloud"): Defines which Azure Cloud to use when using the `service_principal` authentication method. Value is either `AzureCloud` or `AzureUSGovernment`.
2929
- `logs:`
3030
` container_name:` (default = "logs"): Name of the blob container with the logs

receiver/azureblobreceiver/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ type AuthType string
6969
const (
7070
ServicePrincipalAuth AuthType = "service_principal"
7171
ConnectionStringAuth AuthType = "connection_string"
72+
DefaultAuth AuthType = "default"
7273
)
7374

7475
func (e *AuthType) UnmarshalText(text []byte) error {
7576
str := AuthType(text)
7677
switch str {
77-
case ServicePrincipalAuth, ConnectionStringAuth:
78+
case ServicePrincipalAuth, ConnectionStringAuth, DefaultAuth:
7879
*e = str
7980
return nil
8081
default:
81-
return fmt.Errorf("authentication %v is not supported. supported authentications include [%v,%v]", str, ServicePrincipalAuth, ConnectionStringAuth)
82+
return fmt.Errorf("authentication %v is not supported. supported authentications include [%v,%v,%v]", str, ServicePrincipalAuth, ConnectionStringAuth, DefaultAuth)
8283
}
8384
}
8485

receiver/azureblobreceiver/factory.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ func (f *blobReceiverFactory) getBlobEventHandler(cfg *Config, logger *zap.Logge
141141
if err != nil {
142142
return nil, err
143143
}
144+
case DefaultAuth:
145+
cred, err := azidentity.NewDefaultAzureCredential(nil)
146+
if err != nil {
147+
return nil, err
148+
}
149+
bc, err = newBlobClientFromCredential(cfg.StorageAccountURL, cred, logger)
150+
if err != nil {
151+
return nil, err
152+
}
144153
default:
145154
return nil, fmt.Errorf("unknown authentication %v", cfg.Authentication)
146155
}

0 commit comments

Comments
 (0)