From 5cf0e3243005b1440b14dcaf93d3a7925c21824e Mon Sep 17 00:00:00 2001 From: Anuj Sinha Date: Thu, 22 Feb 2024 13:22:52 -0800 Subject: [PATCH 1/4] build: setup ML workspace and VM cluster provisioning via bicep scripts --- azureml/bicep/azuredeploy.parameters.json | 15 +++ azureml/bicep/main.bicep | 108 ++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 azureml/bicep/azuredeploy.parameters.json create mode 100644 azureml/bicep/main.bicep diff --git a/azureml/bicep/azuredeploy.parameters.json b/azureml/bicep/azuredeploy.parameters.json new file mode 100644 index 0000000..041fb7d --- /dev/null +++ b/azureml/bicep/azuredeploy.parameters.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "testname" + }, + "environment": { + "value": "testenv" + }, + "location": { + "value": "westus" + } + } +} diff --git a/azureml/bicep/main.bicep b/azureml/bicep/main.bicep new file mode 100644 index 0000000..6ac4cd4 --- /dev/null +++ b/azureml/bicep/main.bicep @@ -0,0 +1,108 @@ +@description('Specifies the name of the deployment.') +param name string + +@description('Specifies the name of the environment.') +param environment 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.') +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: location + properties: { + computeType: 'AmlCompute' + properties: { + vmSize: vmSize + scaleSettings: { + minNodeCount: minNodeCount + maxNodeCount: maxNodeCount + } + } + } +} From ab8f23eac2dd09356d10b3d06d0d851cccdecaf7 Mon Sep 17 00:00:00 2001 From: Anuj Sinha Date: Tue, 27 Feb 2024 01:17:37 -0800 Subject: [PATCH 2/4] docs: add readme for execution of bicep scripts --- azureml/bicep/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 azureml/bicep/README.md diff --git a/azureml/bicep/README.md b/azureml/bicep/README.md new file mode 100644 index 0000000..e1e060e --- /dev/null +++ b/azureml/bicep/README.md @@ -0,0 +1,26 @@ +### HOW TO DEPLOY TO AZURE USING BICEP SCRIPTS AND COMMAND LINES + +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="""$current_date" + +example for reference: 'AutoRAML02-26-2024' + +#### STEP 3: TRIGGER DEPLOYMENT +az deployment group create --name $deployment_name --resource-group --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 From de29baf0b6602c23a35c16754c86c8877b8fed03 Mon Sep 17 00:00:00 2001 From: Anuj Sinha Date: Tue, 27 Feb 2024 01:29:12 -0800 Subject: [PATCH 3/4] build: update script for provisioning of VM cluster --- azureml/bicep/azuredeploy.parameters.json | 7 +++++-- azureml/bicep/main.bicep | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/azureml/bicep/azuredeploy.parameters.json b/azureml/bicep/azuredeploy.parameters.json index 041fb7d..d92a31f 100644 --- a/azureml/bicep/azuredeploy.parameters.json +++ b/azureml/bicep/azuredeploy.parameters.json @@ -3,13 +3,16 @@ "contentVersion": "1.0.0.0", "parameters": { "name": { - "value": "testname" + "value": "autora" }, "environment": { - "value": "testenv" + "value": "testenv4" }, "location": { "value": "westus" + }, + "clusterLocation": { + "value": "westus3" } } } diff --git a/azureml/bicep/main.bicep b/azureml/bicep/main.bicep index 6ac4cd4..9c7ff16 100644 --- a/azureml/bicep/main.bicep +++ b/azureml/bicep/main.bicep @@ -4,6 +4,9 @@ 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 @@ -81,7 +84,6 @@ resource workspaceName 'Microsoft.MachineLearningServices/workspaces@2023-10-01' location: location properties: { friendlyName: workspaceName_var - storageAccount: storageAccount keyVault: keyVault applicationInsights: applicationInsights @@ -94,7 +96,7 @@ resource workspaceName 'Microsoft.MachineLearningServices/workspaces@2023-10-01' resource clusterName 'Microsoft.MachineLearningServices/workspaces/computes@2021-01-01' = { parent: workspaceName name: clusterName_var - location: location + location: clusterLocation properties: { computeType: 'AmlCompute' properties: { From bc1768b95d709acbc8eb7971d405764bf721925b Mon Sep 17 00:00:00 2001 From: Anuj Sinha Date: Tue, 27 Feb 2024 01:30:13 -0800 Subject: [PATCH 4/4] docs: update README.md for prerequisite steps --- azureml/bicep/README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/azureml/bicep/README.md b/azureml/bicep/README.md index e1e060e..8d1a952 100644 --- a/azureml/bicep/README.md +++ b/azureml/bicep/README.md @@ -1,17 +1,40 @@ -### HOW TO DEPLOY TO AZURE USING BICEP SCRIPTS AND COMMAND LINES +## 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 "" +az configure --defaults workspace= group= location= +``` 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="""$current_date" +``` example for reference: 'AutoRAML02-26-2024' #### STEP 3: TRIGGER DEPLOYMENT +``` az deployment group create --name $deployment_name --resource-group --template-file ./main.bicep --parameters ./azuredeploy.parameters.json --verbose --confirm-with-what-if +``` #### STEP 4: CONFIRM CHANGES (y/N)