diff --git a/plugins/nf-azure/src/main/nextflow/cloud/azure/file/AzPathFactory.groovy b/plugins/nf-azure/src/main/nextflow/cloud/azure/file/AzPathFactory.groovy index 5e80a0bbb6..4c5b20525f 100644 --- a/plugins/nf-azure/src/main/nextflow/cloud/azure/file/AzPathFactory.groovy +++ b/plugins/nf-azure/src/main/nextflow/cloud/azure/file/AzPathFactory.groovy @@ -48,6 +48,11 @@ class AzPathFactory extends FileSystemPathFactory { if( uri.startsWith('az:///') ) throw new IllegalArgumentException("Invalid Azure path URI - make sure the schema prefix does not container more than two slash characters - offending value: $uri") + final storageAccountName = AzConfig.getConfig().storage().accountName + if (uri.startsWith("az://${storageAccountName}.") ) { + uri = uri.replace("az://${storageAccountName}.","az://") + } + final storageConfigEnv = AzConfig.getConfig().storage().getEnv() final activeDirectoryConfigEnv = AzConfig.getConfig().activeDirectory().getEnv() final managedIdentityConfigEnv = AzConfig.getConfig().managedIdentity().getEnv() diff --git a/plugins/nf-azure/src/test/nextflow/cloud/azure/file/AzPathFactoryTest.groovy b/plugins/nf-azure/src/test/nextflow/cloud/azure/file/AzPathFactoryTest.groovy index a5fb0f4eca..8c6a9e03ba 100644 --- a/plugins/nf-azure/src/test/nextflow/cloud/azure/file/AzPathFactoryTest.groovy +++ b/plugins/nf-azure/src/test/nextflow/cloud/azure/file/AzPathFactoryTest.groovy @@ -38,7 +38,7 @@ class AzPathFactoryTest extends Specification { cleanup: Global.session = null - + where: AZ_URI | CONTAINER | BLOB 'az://my-data/foo/bar' | 'my-data' | 'foo/bar' @@ -46,6 +46,36 @@ class AzPathFactoryTest extends Specification { } + def 'should create az azure path and remove storage account from the beginning of the path, if present' () { + given: + def CONFIG = [azure: [ + storage: [ + accountKey: System.getenv('AZURE_STORAGE_ACCOUNT_KEY'), + accountName: System.getenv('AZURE_STORAGE_ACCOUNT_NAME'), + ] + ]] + Global.session = Mock(Session) { getConfig() >> CONFIG } + and: + + when: + def path = AzPathFactory.parse(AZ_URI) + then: + path instanceof AzPath + (path as AzPath).containerName == CONTAINER + (path as AzPath).blobName() == BLOB + + cleanup: + Global.session = null + + where: + storageAccount | AZ_URI | CONTAINER | BLOB + System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/foo/bar" | 'my-data' | 'foo/bar' + System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/data/*{1,2}.fq.gz" | 'my-data' | 'data/*{1,2}.fq.gz' + System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/${storageAccount}.bar" | 'my-data' | "${storageAccount}.bar" + System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.${storageAccount}./foo/bar" | "${storageAccount}." | 'foo/bar' + System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://my-data/${storageAccount}.txt" | 'my-data' | "${storageAccount}.txt" + + } def 'should throw illegal path' () { given: