From 369423405f8b3cd093c35c7ba18d24a104b6ddca Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Wed, 5 Jun 2024 11:27:10 +0000 Subject: [PATCH] Update plugins/inputs/azure_monitor/azure_monitor.go Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com> --- plugins/inputs/azure_monitor/azure_monitor.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/plugins/inputs/azure_monitor/azure_monitor.go b/plugins/inputs/azure_monitor/azure_monitor.go index 984c33de6a798..28167ffb1d5cd 100644 --- a/plugins/inputs/azure_monitor/azure_monitor.go +++ b/plugins/inputs/azure_monitor/azure_monitor.go @@ -4,7 +4,6 @@ package azure_monitor import ( _ "embed" "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "sync" @@ -160,22 +159,16 @@ func (acm *azureClientsManager) createAzureClients( clientID string, clientSecret string, tenantID string, -) (azureClients *receiver.AzureClients, err error) { - var token azcore.TokenCredential +) (*receiver.AzureClients, error) { if clientSecret != "" { - azureClients, err = receiver.CreateAzureClients(subscriptionID, clientID, clientSecret, tenantID) - } else { - if token, err = azidentity.NewDefaultAzureCredential(&azidentity.DefaultAzureCredentialOptions{ - TenantID: tenantID, - }); err == nil { - azureClients, err = receiver.CreateAzureClientsWithCreds(subscriptionID, token) - } + return receiver.CreateAzureClients(subscriptionID, clientID, clientSecret, tenantID) } + + token, err := azidentity.NewDefaultAzureCredential(&azidentity.DefaultAzureCredentialOptions{TenantID: tenantID}) if err != nil { - return nil, fmt.Errorf("error creating Azure clients: %w", err) + return nil, fmt.Errorf("error creating Azure token: %w", err) } - - return azureClients, nil + return receiver.CreateAzureClientsWithCreds(subscriptionID, token) } func init() {