Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private AML: Dockerfile with Nexus config #3424

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 128 additions & 2 deletions templates/workspace_services/azureml/porter.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
schemaVersion: 1.0.0
name: tre-service-azureml
version: 0.8.0
version: 0.9.0
description: "An Azure TRE service for Azure Machine Learning"
registry: azuretre
dockerfile: Dockerfile.tmpl
Expand Down Expand Up @@ -75,6 +75,11 @@ outputs:
applyTo:
- install
- upgrade
- name: azureml_acr_name
type: string
applyTo:
- install
- upgrade
- name: azureml_storage_account_id
type: string
applyTo:
Expand Down Expand Up @@ -117,6 +122,7 @@ outputs:
- upgrade

mixins:
- exec
- terraform:
clientVersion: 1.3.6
- az:
Expand All @@ -137,6 +143,62 @@ install:
auth_client_id: ${ bundle.credentials.auth_client_id }
auth_client_secret: ${ bundle.credentials.auth_client_secret }
auth_tenant_id: ${ bundle.credentials.auth_tenant_id }
public_access_enabled: true
arm_environment: ${ bundle.parameters.arm_environment }
azure_environment: ${ bundle.parameters.azure_environment }
damoodamoo marked this conversation as resolved.
Show resolved Hide resolved
backendConfig:
resource_group_name: ${ bundle.parameters.tfstate_resource_group_name }
storage_account_name: ${ bundle.parameters.tfstate_storage_account_name }
container_name: ${ bundle.parameters.tfstate_container_name }
key: tre-service-azureml-${ bundle.parameters.id }
outputs:
- name: azureml_workspace_name
- name: azureml_acr_id
- name: azureml_acr_name
- name: core_location
- name: azureml_storage_account_id
- name: connection_uri
- name: internal_connection_uri
- name: workspace_address_spaces
- name: aml_subnet_address_prefixes
- name: storage_tag
- name: batch_tag
- name: mcr_tag

- az:
description: "Login to Azure"
arguments:
- login
flags:
identity:
username: ${ bundle.credentials.azure_client_id }

- az:
description: "Build and push private AML image via ACR Tasks"
arguments:
- acr
- build
- ./terraform/private_image/
flags:
registry: ${ bundle.outputs.azureml_acr_name }
image: aml-tre-nexus-image
build-arg: "TRE_LOCATION=${ bundle.outputs.core_location } --build-arg TRE_ID=${ bundle.parameters.tre_id }"

- terraform:
description: "Update ACR to close network"
vars:
workspace_id: ${ bundle.parameters.workspace_id }
tre_id: ${ bundle.parameters.tre_id }
tre_resource_id: ${ bundle.parameters.id }
display_name: ${ bundle.parameters.display_name }
description: ${ bundle.parameters.description }
address_space: ${ bundle.parameters.address_space }
is_exposed_externally: ${ bundle.parameters.is_exposed_externally }
arm_tenant_id: ${ bundle.credentials.azure_tenant_id }
auth_client_id: ${ bundle.credentials.auth_client_id }
auth_client_secret: ${ bundle.credentials.auth_client_secret }
auth_tenant_id: ${ bundle.credentials.auth_tenant_id }
public_access_enabled: false
arm_environment: ${ bundle.parameters.arm_environment }
azure_environment: ${ bundle.parameters.azure_environment }
backendConfig:
Expand All @@ -147,6 +209,7 @@ install:
outputs:
- name: azureml_workspace_name
- name: azureml_acr_id
- name: azureml_acr_name
- name: azureml_storage_account_id
- name: connection_uri
- name: internal_connection_uri
Expand All @@ -158,7 +221,7 @@ install:

upgrade:
- terraform:
description: "Upgrade Azure ML Service"
description: "Upgrade Azure ML Service, with open network"
vars:
workspace_id: ${ bundle.parameters.workspace_id }
tre_id: ${ bundle.parameters.tre_id }
Expand All @@ -171,7 +234,69 @@ upgrade:
auth_client_id: ${ bundle.credentials.auth_client_id }
auth_client_secret: ${ bundle.credentials.auth_client_secret }
auth_tenant_id: ${ bundle.credentials.auth_tenant_id }
public_access_enabled: true
arm_environment: ${ bundle.parameters.arm_environment }
azure_environment: ${ bundle.parameters.azure_environment }
backendConfig:
resource_group_name: ${ bundle.parameters.tfstate_resource_group_name }
storage_account_name: ${ bundle.parameters.tfstate_storage_account_name }
container_name: ${ bundle.parameters.tfstate_container_name }
key: tre-service-azureml-${ bundle.parameters.id }
outputs:
- name: azureml_workspace_name
- name: azureml_acr_id
- name: azureml_acr_name
- name: core_location
- name: azureml_storage_account_id
- name: connection_uri
- name: internal_connection_uri
- name: workspace_address_spaces
- name: aml_subnet_address_prefixes
- name: storage_tag
- name: batch_tag
- name: mcr_tag

- exec:
command: sleep # wait for public network access to _actually_ take effect
arguments:
- "30"

- az:
description: "Login to Azure"
arguments:
- login
flags:
identity:
username: ${ bundle.credentials.azure_client_id }

- az:
description: "Build and push private AML image via ACR Tasks"
arguments:
- acr
- build
- ./terraform/private_image/
flags:
registry: ${ bundle.outputs.azureml_acr_name }
image: aml-tre-nexus-image
build-arg: "TRE_LOCATION=${ bundle.outputs.core_location } --build-arg TRE_ID=${ bundle.parameters.tre_id }"

- terraform:
description: "Update ACR to close network"
vars:
workspace_id: ${ bundle.parameters.workspace_id }
tre_id: ${ bundle.parameters.tre_id }
tre_resource_id: ${ bundle.parameters.id }
display_name: ${ bundle.parameters.display_name }
description: ${ bundle.parameters.description }
address_space: ${ bundle.parameters.address_space }
is_exposed_externally: ${ bundle.parameters.is_exposed_externally }
arm_tenant_id: ${ bundle.credentials.azure_tenant_id }
auth_client_id: ${ bundle.credentials.auth_client_id }
auth_client_secret: ${ bundle.credentials.auth_client_secret }
auth_tenant_id: ${ bundle.credentials.auth_tenant_id }
public_access_enabled: false
arm_environment: ${ bundle.parameters.arm_environment }
azure_environment: ${ bundle.parameters.azure_environment }
backendConfig:
resource_group_name: ${ bundle.parameters.tfstate_resource_group_name }
storage_account_name: ${ bundle.parameters.tfstate_storage_account_name }
Expand All @@ -180,6 +305,7 @@ upgrade:
outputs:
- name: azureml_workspace_name
- name: azureml_acr_id
- name: azureml_acr_name
- name: azureml_storage_account_id
- name: connection_uri
- name: internal_connection_uri
Expand Down
6 changes: 1 addition & 5 deletions templates/workspace_services/azureml/terraform/acr.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@


resource "azurerm_container_registry" "acr" {
name = local.acr_name
location = data.azurerm_resource_group.ws.location
resource_group_name = data.azurerm_resource_group.ws.name
sku = "Premium"
admin_enabled = false
public_network_access_enabled = false
public_network_access_enabled = var.public_access_enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, I suspect this might benefit from a comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed - have added comment to explain

tags = local.tre_workspace_service_tags

lifecycle { ignore_changes = [tags] }
Expand Down Expand Up @@ -37,6 +35,4 @@ resource "azurerm_private_endpoint" "acrpe" {
is_manual_connection = false
subresource_names = ["registry"]
}

}

4 changes: 4 additions & 0 deletions templates/workspace_services/azureml/terraform/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ data "azurerm_resource_group" "ws" {
name = "rg-${var.tre_id}-ws-${local.short_workspace_id}"
}

data "azurerm_resource_group" "core" {
name = "rg-${var.tre_id}"
}

data "azurerm_virtual_network" "ws" {
name = "vnet-${var.tre_id}-ws-${local.short_workspace_id}"
resource_group_name = data.azurerm_resource_group.ws.name
Expand Down
8 changes: 8 additions & 0 deletions templates/workspace_services/azureml/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ output "azureml_acr_id" {
value = azurerm_container_registry.acr.id
}

output "azureml_acr_name" {
value = azurerm_container_registry.acr.name
}

output "core_location" {
value = data.azurerm_resource_group.core.location
}

output "azureml_storage_account_id" {
value = azurerm_storage_account.aml.id
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://github.com/Azure/AzureML-Containers/blob/master/base/cpu/openmpi4.1.0-ubuntu22.04/Dockerfile

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04@sha256:2c217d40498433d578cd4ec6cc519b49b324da34aca1e0df1930e1552c89af7d

ARG TRE_ID
ARG TRE_LOCATION
ENV NEXUS_PROXY_URL="https://nexus-${TRE_ID}.${TRE_LOCATION}.cloudapp.azure.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this going to need to be updated as per the Gov cloud stuff?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep - have updated to set the endpoint based on cloud type


# Set Nexus Conda
ENV PATH="/anaconda/condabin":$PATH
ENV PATH="/anaconda/bin":$PATH
ENV PATH="/anaconda/envs/py38_default/bin":$PATH

RUN conda config --add channels "${NEXUS_PROXY_URL}/repository/conda-mirror/main/" --system && \
conda config --add channels "${NEXUS_PROXY_URL}/repository/conda-repo/main/" --system && \
conda config --remove channels defaults --system && \
conda config --set channel_alias "${NEXUS_PROXY_URL}/repository/conda-mirror/" --system

# Set PyPi sources
RUN printf "[global]\nindex = %s/repository/pypi/pypi\nindex-url = %s/repository/pypi/simple\ntrusted-host = %s\n" "${NEXUS_PROXY_URL}" "${NEXUS_PROXY_URL}" "${NEXUS_PROXY_URL}" >> /etc/pip.conf
4 changes: 4 additions & 0 deletions templates/workspace_services/azureml/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ variable "auth_client_secret" {
sensitive = true
description = "Used to authenticate into the AAD Tenant to get app role members"
}
variable "public_access_enabled" {
type = bool
default = false
}

variable "arm_environment" {}

Expand Down