diff --git a/azureml/bicep/README.md b/azureml/bicep/README.md new file mode 100644 index 0000000..8d1a952 --- /dev/null +++ b/azureml/bicep/README.md @@ -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 "" +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) + +#### 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 diff --git a/azureml/bicep/azuredeploy.parameters.json b/azureml/bicep/azuredeploy.parameters.json new file mode 100644 index 0000000..d92a31f --- /dev/null +++ b/azureml/bicep/azuredeploy.parameters.json @@ -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" + } + } +} diff --git a/azureml/bicep/main.bicep b/azureml/bicep/main.bicep new file mode 100644 index 0000000..9c7ff16 --- /dev/null +++ b/azureml/bicep/main.bicep @@ -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.') +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 + } + } + } +}