Skip to content

Commit d1f70f5

Browse files
Allow users to provide implicit managed identity to Azure Batch (#6144) [ci fast]
Signed-off-by: adamrtalbot <12817534+adamrtalbot@users.noreply.github.com> Signed-off-by: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com> Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent ed40709 commit d1f70f5

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

docs/reference/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ The following settings are available:
417417
`azure.batch.poolIdentityClientId`
418418
: :::{versionadded} 25.05.0-edge
419419
:::
420-
: 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.
420+
: 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.
421421

422422
`azure.managedIdentity.clientId`
423423
: 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`.

plugins/nf-azure/src/main/nextflow/cloud/azure/fusion/AzFusionEnv.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ class AzFusionEnv implements FusionEnv {
6464
// If pool has a managed identity, ONLY add the MSI client ID
6565
// DO NOT add any SAS token or reference cfg.storage().sasToken
6666
if (managedIdentityId) {
67-
result.FUSION_AZ_MSI_CLIENT_ID = managedIdentityId
67+
// Fusion will try and pick up a managed identity that is available.
68+
// We recommend explicitly setting the config item to the managed ID so you know which one is being used.
69+
// However if set to 'true' it will use whichever is available.
70+
// This can be helpful if the pools have different managed identities.
71+
if (managedIdentityId != 'auto') {
72+
result.FUSION_AZ_MSI_CLIENT_ID = managedIdentityId
73+
}
6874
// No SAS token is added or generated
6975
return result
7076
}

plugins/nf-azure/src/test/nextflow/cloud/azure/fusion/AzFusionEnvTest.groovy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,26 @@ class AzFusionEnvTest extends Specification {
243243
env.size() == 2 // Only account name and managed identity
244244
}
245245

246+
def 'should not provide explicit managed identity when pool identity is set to true'() {
247+
given:
248+
def NAME = 'myaccount'
249+
Global.session = Mock(Session) {
250+
getConfig() >> [azure: [
251+
storage: [accountName: NAME],
252+
batch: [poolIdentityClientId: 'auto']
253+
]]
254+
}
255+
256+
when:
257+
def config = Mock(FusionConfig)
258+
def fusionEnv = new AzFusionEnv()
259+
def env = fusionEnv.getEnvironment('az', config)
260+
261+
then:
262+
env.AZURE_STORAGE_ACCOUNT == NAME
263+
!env.FUSION_AZ_MSI_CLIENT_ID
264+
!env.AZURE_STORAGE_SAS_TOKEN // SAS token should NOT be present
265+
env.size() == 1 // Only account name
266+
}
267+
246268
}

0 commit comments

Comments
 (0)