@@ -27,6 +27,7 @@ import (
2727 "github.com/Azure/azure-sdk-for-go/sdk/azcore"
2828 azureautorest "github.com/Azure/go-autorest/autorest/azure"
2929 "github.com/Azure/go-autorest/autorest/azure/auth"
30+ infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
3031)
3132
3233// AzureClients contains all the Azure clients used by the scopes.
@@ -36,6 +37,8 @@ type AzureClients struct {
3637 TokenCredential azcore.TokenCredential
3738 ResourceManagerEndpoint string
3839 ResourceManagerVMDNSSuffix string
40+
41+ authType infrav1.IdentityType
3942}
4043
4144// CloudEnvironment returns the Azure environment the controller runs in.
@@ -73,7 +76,7 @@ func (c *AzureClients) Token() azcore.TokenCredential {
7376// ClientID).
7477func (c * AzureClients ) HashKey () string {
7578 hasher := sha256 .New ()
76- _ , _ = hasher .Write ([]byte (c .TenantID () + c .CloudEnvironment () + c .SubscriptionID () + c .ClientID ()))
79+ _ , _ = hasher .Write ([]byte (c .TenantID () + c .CloudEnvironment () + c .SubscriptionID () + c .ClientID () + string ( c . authType ) ))
7780 return base64 .URLEncoding .EncodeToString (hasher .Sum (nil ))
7881}
7982
@@ -107,6 +110,8 @@ func (c *AzureClients) setCredentialsWithProvider(ctx context.Context, subscript
107110 }
108111 c .Values ["AZURE_CLIENT_SECRET" ] = strings .TrimSuffix (clientSecret , "\n " )
109112
113+ c .authType = credentialsProvider .Type ()
114+
110115 tokenCredential , err := credentialsProvider .GetTokenCredential (ctx , c .ResourceManagerEndpoint , c .Environment .ActiveDirectoryEndpoint , c .Environment .TokenAudience )
111116 if err != nil {
112117 return err
0 commit comments