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 4d95995
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions plugins/inputs/azure_monitor/azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,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 receiver.CreateAzureClientsWithCreds(subscriptionID, token)

return azureClients, nil
}
Expand Down

0 comments on commit 4d95995

Please sign in to comment.