Skip to content

Commit

Permalink
Update plugins/inputs/azure_monitor/azure_monitor.go
Browse files Browse the repository at this point in the history
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
  • Loading branch information
redbaron and srebhan committed Jun 5, 2024
1 parent 3d818d9 commit 6a740d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ require (
github.com/Azure/azure-amqp-common-go/v4 v4.2.0 // indirect
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0 // indirect
Expand Down
19 changes: 6 additions & 13 deletions plugins/inputs/azure_monitor/azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 6a740d3

Please sign in to comment.