Skip to content

Allow users to provide implicit managed identity to Azure Batch when pool identity is set to true #6144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ The following settings are available:
`azure.batch.poolIdentityClientId`
: :::{versionadded} 25.05.0-edge
:::
: Specify the client ID for an Azure [managed identity](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview) that is available on all Azure Batch node pools. This identity will be used for task-level authentication to Azure services. See {ref}`azure-managed-identities` for more details.
: Specify the client ID for an Azure [managed identity](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview) that is available on all Azure Batch node pools. This identity will be used by Fusion to authenticate to Azure storage. If set to `'auto'`, Fusion will use the first available managed identity.

`azure.managedIdentity.clientId`
: Specify the client ID for an Azure [managed identity](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview). See {ref}`azure-managed-identities` for more details. Defaults to environment variable `AZURE_MANAGED_IDENTITY_USER`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ class AzFusionEnv implements FusionEnv {
// If pool has a managed identity, ONLY add the MSI client ID
// DO NOT add any SAS token or reference cfg.storage().sasToken
if (managedIdentityId) {
result.FUSION_AZ_MSI_CLIENT_ID = managedIdentityId
// Fusion will try and pick up a managed identity that is available.
// We recommend explicitly setting the config item to the managed ID so you know which one is being used.
// However if set to 'true' it will use whichever is available.
// This can be helpful if the pools have different managed identities.
if (managedIdentityId != 'auto') {
result.FUSION_AZ_MSI_CLIENT_ID = managedIdentityId
}
// No SAS token is added or generated
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,26 @@ class AzFusionEnvTest extends Specification {
env.size() == 2 // Only account name and managed identity
}

def 'should not provide explicit managed identity when pool identity is set to true'() {
given:
def NAME = 'myaccount'
Global.session = Mock(Session) {
getConfig() >> [azure: [
storage: [accountName: NAME],
batch: [poolIdentityClientId: 'auto']
]]
}

when:
def config = Mock(FusionConfig)
def fusionEnv = new AzFusionEnv()
def env = fusionEnv.getEnvironment('az', config)

then:
env.AZURE_STORAGE_ACCOUNT == NAME
!env.FUSION_AZ_MSI_CLIENT_ID
!env.AZURE_STORAGE_SAS_TOKEN // SAS token should NOT be present
env.size() == 1 // Only account name
}

}
Loading