@@ -83,6 +83,7 @@ const (
83
83
storageSPNClientIDField = "azurestoragespnclientid"
84
84
storageSPNTenantIDField = "azurestoragespntenantid"
85
85
storageAuthTypeField = "azurestorageauthtype"
86
+ storageAuthTypeMSI = "msi"
86
87
storageIdentityClientIDField = "azurestorageidentityclientid"
87
88
storageIdentityObjectIDField = "azurestorageidentityobjectid"
88
89
storageIdentityResourceIDField = "azurestorageidentityresourceid"
@@ -635,7 +636,7 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
635
636
if spnTenantID != "" {
636
637
storageSPNTenantID = spnTenantID
637
638
}
638
- if err != nil && strings .EqualFold (azureStorageAuthType , "msi" ) {
639
+ if err != nil && strings .EqualFold (azureStorageAuthType , storageAuthTypeMSI ) {
639
640
klog .V (2 ).Infof ("ignore error(%v) since secret is optional for auth type(%s)" , err , azureStorageAuthType )
640
641
err = nil
641
642
}
@@ -708,6 +709,23 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
708
709
authEnv = append (authEnv , "AZURE_STORAGE_SPN_TENANT_ID=" + storageSPNTenantID )
709
710
}
710
711
712
+ if azureStorageAuthType == storageAuthTypeMSI {
713
+ // check whether authEnv contains AZURE_STORAGE_IDENTITY_ prefix
714
+ containsIdentityEnv := false
715
+ for _ , env := range authEnv {
716
+ if strings .HasPrefix (env , "AZURE_STORAGE_IDENTITY_" ) {
717
+ klog .V (2 ).Infof ("AZURE_STORAGE_IDENTITY_ is already set in authEnv, skip setting it again" )
718
+ containsIdentityEnv = true
719
+ break
720
+ }
721
+ }
722
+ if ! containsIdentityEnv && d .cloud != nil && d .cloud .Config .AzureAuthConfig .UserAssignedIdentityID != "" {
723
+ klog .V (2 ).Infof ("azureStorageAuthType is set to %s, add AZURE_STORAGE_IDENTITY_CLIENT_ID(%s) into authEnv" ,
724
+ azureStorageAuthType , d .cloud .Config .AzureAuthConfig .UserAssignedIdentityID )
725
+ authEnv = append (authEnv , "AZURE_STORAGE_IDENTITY_CLIENT_ID=" + d .cloud .Config .AzureAuthConfig .UserAssignedIdentityID )
726
+ }
727
+ }
728
+
711
729
return rgName , accountName , accountKey , containerName , authEnv , err
712
730
}
713
731
0 commit comments