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

build: setup ML workspace and VM cluster provisioning via bicep scripts #43

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
49 changes: 49 additions & 0 deletions azureml/bicep/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## HOW TO DEPLOY TO AZURE USING BICEP SCRIPTS AND COMMAND LINES

### STEP 0: PREREQUISITES
Ignore pre-requisites if already done as part of the project setup instruction in the parent README.md
[Install Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)

Add the ML extension:
```
az extension add --name ml
```

Configure the CLI:

```
az login
az account set --subscription "<your subscription name>"
az configure --defaults workspace=<aml workspace> group=<resource group> location=<location, e.g. westus3>
```

Execute the following commands on your terminal(mac)

#### STEP 1: SET THE REQUIRED VARIABLES
```
current_date=$(date +%m-%d-%Y)
```

#### STEP 2: SET THE DEPLOYMENT NAME
```
deployment_name="<name_as_per_specification>""$current_date"
```

example for reference: 'AutoRAML02-26-2024'

#### STEP 3: TRIGGER DEPLOYMENT
```
az deployment group create --name $deployment_name --resource-group <resource_group_name on azure> --template-file ./main.bicep --parameters ./azuredeploy.parameters.json --verbose --confirm-with-what-if
```

#### STEP 4: CONFIRM CHANGES (y/N)

#### STEP 5: TRACK THE STATUS OF YOUR DEPLOYMENT UNDER
- https://portal.azure.com/#view/HubsExtension/BrowseResourceGroups
- Click on your resource group
- Click on the 'Deployments' tab on the left panel
- Check the status of the deployment name for which your triggered deployment.

Further references:
https://medium.com/codex/using-bicep-to-create-workspace-resources-and-get-started-with-azure-machine-learning-bcc57fd4fd09
https://medium.com/@dmitri.mahayana/creating-virtual-assistance-using-with-llama-2-7b-chat-model-9f693c8250ee
18 changes: 18 additions & 0 deletions azureml/bicep/azuredeploy.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "autora"
},
"environment": {
"value": "testenv4"
},
"location": {
"value": "westus"
},
"clusterLocation": {
"value": "westus3"
}
}
}
110 changes: 110 additions & 0 deletions azureml/bicep/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@description('Specifies the name of the deployment.')
param name string

@description('Specifies the name of the environment.')
param environment string

@description('Specifies the region of the cluster.')
param clusterLocation string

@description('Specifies the location of the Azure Machine Learning workspace and dependent resources.')
param location string = resourceGroup().location

@description('The minimum number of nodes to use on the cluster. If not specified, defaults to 0')
param minNodeCount int = 0
@description(' The maximum number of nodes to use on the cluster. If not specified, defaults to 4.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment says zero, but the default is 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The cluster does get provisioned with a minimum of 0 nodes. If I remember correctly, the cluster we had also had 0 as its minimum nodes.

param maxNodeCount int = 1

@description('Specifies whether to reduce telemetry collection and enable additional encryption.')
param hbi_workspace bool = false

@description(' The size of agent VMs. More details can be found here: https://aka.ms/azureml-vm-details.')
param vmSize string = 'Standard_NC6s_v3'

var tenantId = subscription().tenantId
var storageAccountName_var = 'st${name}${environment}'
var keyVaultName_var = 'kv-${name}-${environment}'
var applicationInsightsName_var = 'appi-${name}-${environment}'
var containerRegistryName_var = 'cr${name}${environment}'
var workspaceName_var = 'mlw${name}${environment}'
var clusterName_var = 'clust${name}${environment}'
var storageAccount = storageAccountName.id
var keyVault = keyVaultName.id
var applicationInsights = applicationInsightsName.id
var containerRegistry = containerRegistryName.id

resource storageAccountName 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageAccountName_var
location: location
sku: {
name: 'Standard_RAGRS'
}
kind: 'StorageV2'
}

resource keyVaultName 'Microsoft.KeyVault/vaults@2023-07-01' = {
name: keyVaultName_var
location: location
properties: {
sku: {
family: 'A'
name: 'standard'
}
tenantId: tenantId
accessPolicies: []
enableSoftDelete: true
}
}

resource applicationInsightsName 'Microsoft.Insights/components@2020-02-02' = {
name: applicationInsightsName_var
location: location
kind: 'web'
properties: {
Application_Type: 'web'
}
}

resource containerRegistryName 'Microsoft.ContainerRegistry/registries@2023-11-01-preview' = {
name: containerRegistryName_var
location: location
sku: {
name: 'Standard'
}
properties: {
adminUserEnabled: true
}
}

resource workspaceName 'Microsoft.MachineLearningServices/workspaces@2023-10-01' = {
identity: {
type: 'SystemAssigned'
}
name: workspaceName_var
location: location
properties: {
friendlyName: workspaceName_var
storageAccount: storageAccount
keyVault: keyVault
applicationInsights: applicationInsights
containerRegistry: containerRegistry
hbiWorkspace: hbi_workspace
}
}


resource clusterName 'Microsoft.MachineLearningServices/workspaces/computes@2021-01-01' = {
parent: workspaceName
name: clusterName_var
location: clusterLocation
properties: {
computeType: 'AmlCompute'
properties: {
vmSize: vmSize
scaleSettings: {
minNodeCount: minNodeCount
maxNodeCount: maxNodeCount
}
}
}
}
Loading