Skip to content

Commit

Permalink
Support for deployment in Azure Government Cloud (Workbench-Libs) (#1713
Browse files Browse the repository at this point in the history
)

* azure gov environment support

* Update AzureVmServiceInterp.scala

* Update AzureEnvironmentConfig.scala

* scalafmt

* scalafmt

* Bump azure version

---------

Co-authored-by: Jonathon Saunders <[email protected]>
  • Loading branch information
bennettn4 and jsaun authored Dec 17, 2024
1 parent 7dd3739 commit b25c29d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
@@ -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))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b25c29d

Please sign in to comment.