From 939664aaa444945a6fa2a24ce2482418fa740b85 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 5 Nov 2024 16:50:23 -0500 Subject: [PATCH 1/6] azure gov environment support --- ...zureApplicationInsightsServiceInterp.scala | 2 +- .../azure/AzureBatchServiceInterp.scala | 2 +- .../azure/AzureContainerServiceInterp.scala | 5 ++++- .../azure/AzureEnvironmentConfig.scala | 20 +++++++++++++++++++ .../workbench/azure/AzureRelayInterp.scala | 2 +- .../azure/AzureVmServiceInterp.scala | 2 +- 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala 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..e31d0311c 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,7 @@ 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..c769bbc92 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,7 @@ 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..1463b754c --- /dev/null +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala @@ -0,0 +1,20 @@ +package org.broadinstitute.dsde.workbench.azure + +import com.azure.core.management.AzureEnvironment + +object AzureEnvironmentConfig { + val AZURE_ENVIRONMENT_CONFIG = "AZURE_ENVIRONMENT" + + private val Azure: String = "AZURE" + private val AzureGov: String = "AZURE_GOV" + + 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..06c5eaf40 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,7 @@ 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..12dd9c943 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,7 @@ 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)) } From 21b542fab70fa75e3d86aba4a836790232ed601c Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Wed, 6 Nov 2024 10:28:26 -0500 Subject: [PATCH 2/6] Update AzureVmServiceInterp.scala --- .../dsde/workbench/azure/AzureVmServiceInterp.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 12dd9c943..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, AzureEnvironmentConfig.fromCurrentHostingEnv() + new AzureProfile(azureCloudContext.tenantId.value, + azureCloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(ComputeManager.authenticate(clientSecretCredential, azureProfile)) } From c18669a730aa8faef837794ef38aaeab902241ee Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Mon, 18 Nov 2024 14:19:32 -0500 Subject: [PATCH 3/6] Update AzureEnvironmentConfig.scala --- .../dsde/workbench/azure/AzureEnvironmentConfig.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 index 1463b754c..fe10841c2 100644 --- a/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala +++ b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureEnvironmentConfig.scala @@ -5,8 +5,8 @@ import com.azure.core.management.AzureEnvironment object AzureEnvironmentConfig { val AZURE_ENVIRONMENT_CONFIG = "AZURE_ENVIRONMENT" - private val Azure: String = "AZURE" - private val AzureGov: String = "AZURE_GOV" + private val Azure: String = "AzureCloud" + private val AzureGov: String = "AzureUSGovernmentCloud" def fromString(s: String): AzureEnvironment = s match { case AzureGov => AzureEnvironment.AZURE_US_GOVERNMENT @@ -14,7 +14,6 @@ object AzureEnvironmentConfig { case _ => throw new IllegalArgumentException(s"Unknown Azure environment: $s") } - def fromCurrentHostingEnv(): AzureEnvironment = { - fromString(scala.util.Properties.envOrElse(AZURE_ENVIRONMENT_CONFIG, Azure )) - } + def fromCurrentHostingEnv(): AzureEnvironment = + fromString(scala.util.Properties.envOrElse(AZURE_ENVIRONMENT_CONFIG, Azure)) } From 6faad10691c0700d43b8703e5740d7d725aa4dc6 Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 10 Dec 2024 11:13:35 -0500 Subject: [PATCH 4/6] scalafmt --- .../azure/AzureApplicationInsightsServiceInterp.scala | 5 ++++- .../dsde/workbench/azure/AzureRelayInterp.scala | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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 e31d0311c..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, AzureEnvironmentConfig.fromCurrentHostingEnv()) + 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/AzureRelayInterp.scala b/azure/src/main/scala/org/broadinstitute/dsde/workbench/azure/AzureRelayInterp.scala index 06c5eaf40..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, AzureEnvironmentConfig.fromCurrentHostingEnv()) + new AzureProfile(azureCloudContext.tenantId.value, + azureCloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(RelayManager.authenticate(clientSecretCredential, azureProfile)) } From 6b26bf8baf72758592880d0508dfd1c0fe0d025f Mon Sep 17 00:00:00 2001 From: bennettn4 Date: Tue, 10 Dec 2024 11:22:40 -0500 Subject: [PATCH 5/6] scalafmt --- .../dsde/workbench/azure/AzureBatchServiceInterp.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 c769bbc92..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, AzureEnvironmentConfig.fromCurrentHostingEnv()) + new AzureProfile(cloudContext.tenantId.value, + cloudContext.subscriptionId.value, + AzureEnvironmentConfig.fromCurrentHostingEnv() + ) F.blocking(BatchManager.authenticate(clientSecretCredential, azureProfile)) } } From 3e6dd1d0a775bfc25b2acd23a66450de3098b3fb Mon Sep 17 00:00:00 2001 From: Jonathon Saunders Date: Mon, 16 Dec 2024 23:04:16 -0800 Subject: [PATCH 6/6] Bump azure version --- project/Settings.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(