This is an old revision of the document!
Create an automated CI/CD pipeline using GitHub Actions that:
Provision these with Bicep or Terraform:
cpu-cluster)plaintextCopyEdit.github/workflows/ βββ train-deploy.yml # GitHub Actions workflow infra/ βββ main.bicep # Infrastructure as code ml/ βββ train.py # Model training script βββ score.py # Inference entry point βββ environment.yml # Conda environment for training/deployment βββ register_model.py # Registers trained model βββ pipeline_job.yml # Azure ML pipeline definition (optional)
azure/login GitHub Action)az monitor alert rules)Business Case: Retrain a churn prediction model every week using new customer data.
param location string = resourceGroup().location
param workspaceName string
param storageAccountName string
param keyVaultName string
param appInsightsName string
param logAnalyticsName string
param computeName string = 'cpu-cluster'
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
name: logAnalyticsName
location: location
properties: {
retentionInDays: 30
sku: {
name: 'PerGB2018'
}
}
}
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
name: appInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: logAnalytics.id
}
}
resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {}
}
resource keyVault 'Microsoft.KeyVault/vaults@2023-02-01' = {
name: keyVaultName
location: location
properties: {
tenantId: subscription().tenantId
sku: {
name: 'standard'
family: 'A'
}
accessPolicies: []
enabledForDeployment: true
enabledForTemplateDeployment: true
enableSoftDelete: true
}
}
resource mlWorkspace 'Microsoft.MachineLearningServices/workspaces@2023-04-01' = {
name: workspaceName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
description: 'Demo ML workspace for CI/CD'
storageAccount: storage.id
applicationInsights: appInsights.id
keyVault: keyVault.id
friendlyName: workspaceName
}
}
resource computeCluster 'Microsoft.MachineLearningServices/workspaces/computes@2023-04-01' = {
name: computeName
parent: mlWorkspace
location: location
dependsOn: [mlWorkspace]
properties: {
computeType: 'AmlCompute'
properties: {
vmSize: 'STANDARD_DS3_V2'
scaleSettings: {
minNodeCount: 0
maxNodeCount: 2
idleTimeBeforeScaleDown: 'PT5M'
}
}
}
}
Deployed with
az deployment group create \
--name ml-cicd-deployment \
--resource-group don-test-rg \
--template-file main.bicep \
--parameters workspaceName="don-ml-workspace" \
storageAccountName="donmlstorage" \
keyVaultName="donkv" \
appInsightsName="donappinsights" \
logAnalyticsName="donloganalytics"