diff --git a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureApplicationInsightsServiceInterp.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureApplicationInsightsServiceInterp.scala index b119b30f6..36e909c8e 100644 --- a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureApplicationInsightsServiceInterp.scala +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureApplicationInsightsServiceInterp.scala @@ -32,7 +32,10 @@ class AzureApplicationInsightsServiceInterp[F[_]](clientSecretCredential: Client private def buildApplicationInsightsManager(cloudContext: AzureCloudContext): F[ApplicationInsightsManager] = { val azureProfile = - new AzureProfile(cloudContext.tenantId.value, cloudContext.subscriptionId.value, AzureEnvironment.AZURE) + new AzureProfile(cloudContext.tenantId.value, + cloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(ApplicationInsightsManager.authenticate(clientSecretCredential, azureProfile)) } } diff --git a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureBatchServiceInterp.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureBatchServiceInterp.scala index cb3ed8f47..2872e58cf 100644 --- a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureBatchServiceInterp.scala +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureBatchServiceInterp.scala @@ -32,7 +32,10 @@ class AzureBatchServiceInterp[F[_]](clientSecretCredential: ClientSecretCredenti private def buildBatchManager(cloudContext: AzureCloudContext): F[BatchManager] = { val azureProfile = - new AzureProfile(cloudContext.tenantId.value, cloudContext.subscriptionId.value, AzureEnvironment.AZURE) + new AzureProfile(cloudContext.tenantId.value, + cloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(BatchManager.authenticate(clientSecretCredential, azureProfile)) } } diff --git a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureContainerServiceInterp.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureContainerServiceInterp.scala index 7c9bb0d37..64c231e3e 100644 --- a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureContainerServiceInterp.scala +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureContainerServiceInterp.scala @@ -94,7 +94,10 @@ class AzureContainerServiceInterp[F[_]](clientSecretCredential: ClientSecretCred private def buildContainerServiceManager(cloudContext: AzureCloudContext): F[ContainerServiceManager] = { val azureProfile = - new AzureProfile(cloudContext.tenantId.value, cloudContext.subscriptionId.value, AzureEnvironment.AZURE) + new AzureProfile(cloudContext.tenantId.value, + cloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(ContainerServiceManager.authenticate(clientSecretCredential, azureProfile)) } } diff --git a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala new file mode 100644 index 000000000..fe10841c2 --- /dev/null +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala @@ -0,0 +1,19 @@ +package org.broadinstitute.dsde.workbench.azure + +import com.azure.core.management.AzureEnvironment + +object AzureEnvironmentConfig { + val AZURE_ENVIRONMENT_CONFIG = "AZURE_ENVIRONMENT" + + private val Azure: String = "AzureCloud" + private val AzureGov: String = "AzureUSGovernmentCloud" + + def fromString(s: String): AzureEnvironment = s match { + case AzureGov => AzureEnvironment.AZURE_US_GOVERNMENT + case Azure => AzureEnvironment.AZURE + case _ => throw new IllegalArgumentException(s"Unknown Azure environment: $s") + } + + def fromCurrentHostingEnv(): AzureEnvironment = + fromString(scala.util.Properties.envOrElse(AZURE_ENVIRONMENT_CONFIG, Azure)) +} diff --git a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureRelayInterp.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureRelayInterp.scala index 36a291e69..e3ba6aab9 100644 --- a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureRelayInterp.scala +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureRelayInterp.scala @@ -124,7 +124,10 @@ class AzureRelayInterp[F[_]](clientSecretCredential: ClientSecretCredential)(imp private def buildRelayManager(azureCloudContext: AzureCloudContext): F[RelayManager] = { val azureProfile = - new AzureProfile(azureCloudContext.tenantId.value, azureCloudContext.subscriptionId.value, AzureEnvironment.AZURE) + new AzureProfile(azureCloudContext.tenantId.value, + azureCloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(RelayManager.authenticate(clientSecretCredential, azureProfile)) } diff --git a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureVmServiceInterp.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureVmServiceInterp.scala index 4bdc92679..fcfa9c84f 100644 --- a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureVmServiceInterp.scala +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureVmServiceInterp.scala @@ -97,7 +97,10 @@ class AzureVmServiceInterp[F[_]](clientSecretCredential: ClientSecretCredential) private def buildComputeManager(azureCloudContext: AzureCloudContext): F[ComputeManager] = { val azureProfile = - new AzureProfile(azureCloudContext.tenantId.value, azureCloudContext.subscriptionId.value, AzureEnvironment.AZURE) + new AzureProfile(azureCloudContext.tenantId.value, + azureCloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(ComputeManager.authenticate(clientSecretCredential, azureProfile)) } diff --git a/project/Settings.scala b/project/Settings.scala index 83e8fb5b8..ae5970779 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -124,7 +124,7 @@ object Settings { val azureSettings = commonSettings ++ List( name := "workbench-azure", libraryDependencies ++= azureDependencies, - version := createVersion("0.9") + version := createVersion("0.10") ) ++ publishSettings val openTelemetrySettings = commonSettings ++ List(