In this execise, we'll deploy a DevOps pipeline that will enable the following scenario:
- Sign in to Azure DevOps
- Select
Create project
(you can keep it private) - Provide Project Name:
aml-mlops-workshop-123
(or something else) and selectCreate
Next, we'll clone the workshop repo into the project's "local" repo:
- Goto Repos, then select
Import a repository
- Enter the
Clone URL
:https://github.com/csiebler/azure-machine-learning-mlops-workshop
and import it
Next, we'll authenticate from Azure DevOps to AML, so that Azure DevOps can make calls to AML on our behalf.
- From the left navigation select
Project settings
(at the bottom, the gear icon) and then selectService connections
- Select
Create service connection
and then selectAzure Resource Manager
- Select
Service principal (automatic)
- Keep the default
Scope level
toSubscription
, but update:- Subscription: Select the Azure subscription you've used before
- Resource Group: The resource group you've used before
- Service connection name:
aml_workspace
- Hit
Save
This DevOps pipeline is used to the automatically deploy the Python-based ML training pipeline we've created in one of the earlier exercises.
- Select
Pipelines --> Pipelines
(rocket icon) and selectCreate pipeline
- (Connect step) - Choose
Azure Repos Git
- (Select step) - Select your repo (there should only be one named after your project)
- (Configure step) - Select
Existing Azure Pipelines YAML file
and choose the path to the file/devops-deploy-simple-pipeline/deploy-simple-pipeline.yml
- In the upcoming preview window, update the
variables
section (if you've used the defaults, this should not require any changes):
variables:
resourcegroup: 'aml-mlops-workshop' # replace with your resource group (same as you've used for the Service Connection)
workspace: 'aml-mlops-workshop' # replace with your workspace name (same as you've used for the Service Connection)
aml_compute_target: 'cpu-cluster'
- Review the YAML file, this CI/CD pipeline has six key steps:
- Set Python version on the build agent
- Install Azure Machine Learning CLI (primarily used for authentication to workspace in this example)
- Attach folder to workspace for authentication
- Create the AML Compute target
- Publish pipeline for model training
- Select
Run
to save and run the pipeline.
Lastly, navigate to the AML Studio UI and you should fine your pipeline under Endpoints -> Pipeline Endpoints
. Imported Azure DevOps Pipelines always have weird names, so you can select the pipeline, then click the three dots ...
(upper right corner of the UI), and select Rename
.
❓ Question: Why do we need a service connection?
✅ See solution!
The service connection connects Azure DevOps to the resource group where our Workspace resides in, and therefore gives this connection full control to execute commands in AML.
❓ Question: Why do we use az ml folder attach -w $(workspace) -g $(resourcegroup)
?
✅ See solution!
This command associates our repo (on the build agent) with our workspace. This allows subsequent Python code just call ws = Workspace.from_config()
to authenticate and connect to the workspace.