- Navigate to http://portal.azure.com. Click Create a Resource and enter “machine learning” in the search box
- Choose Machine Learning Service Workspace and click Create
- Enter a workspace name, the resource group and region, and click Create
- In the Azure Portal (http://portal.azure.com ), click the Search button on the top bar
- Search for “Azure Active Directory” and select the option under Services:
- Click “App Registrations” on the left, then click “New application registration”
- Enter the name of your application, and a URL. For convenience and ease of tracking, we suggest you use you’re a unique prefix to your service principals. The URL doesn’t have to be a real URL, you can enter http://invalid
- Once complete, click on the Certificates & Secrets button for your service principal then click Keys
- Click New Client Secret
- Here we will create a password for your service principal. Enter “accessKey” for the description, and 1 year for the expiration. Then click Add. Once you click Add, the password will be displayed only once. Copy the password before leaving the blade, otherwise you won’t be able to see it again. Be sure to copy the Application ID as well, as we’ll need that later on.
- Retrieve the Tenant ID. We’ll need this later. On the left-hand blade, click “Overview” to show the properties of your Azure Active Directory. Copy the Directory (Tenant) ID. This is your Tenant ID.
- Now we need to give access for the Service Principal to use the AzureML Workspace. Open the AzureML Workspace you created, click Access control (IAM) and Add a role assignment to add a user to a role.
- Choose Contributor for the role and enter the name of the service principal you created, then click save.
- Open a browser window and navigate to https://visualstudio.microsoft.com/
- Under Azure DevOps (formerly VSTS) click “Get started for free”
- Once you sign in with a Microsoft user account, enter a project name and choose Private to create a new project
- Once the project is created, click Repos on the left navigation bar
- Click import to import a Git registry, enter https://github.com/chronicle17/DSDevOps, and click Import
- Click Pipelines and then New Pipeline to create a new build
- Select Azure Repos Git, then select the project and repository that you just created and click Continue
- When asked to select a template, choose Empty job
- Enter “Train Model” for the name and choose “Hosted Ubuntu 1604” for the agent pool
- Click on Agent job 1. Change the name to Run Pipeline and click the plus sign to add a task
- In the Add tasks blade, search for python in the search box and add Use Python Version
- Change the name to Use Python 3.6 and enter 3.6 in the Version spec
- Click the plus sign to add a task to the pipeline, search for command, and add Command line
- Change the Display name to “Install Python Packages”. In the Script box, enter
“pip install -r ./environment_setup/requirements.txt”
This will ensure that our build server has all of the packages that we need to build our model. - Add a task to the pipeline. Search for python and choose Python Script
- Change the name to “Train Model on Local” and choose the script path “aml_service/10-TrainOnLocal.py”
- Add another Python script to the pipeline. Change the name to Evaluate Model and the script path to “aml_service/15-EvaluateModel.py”
- Add 4 more Python scripts to the pipeline (hint, you can click Add multiple times)
- Fill out the remaining python scripts with following names and script path
name | script path |
---|---|
Register Model | aml_service/20-RegisterModel.py |
Create Scoring Image | aml_service/30-CreateScoringImage.py |
Deploy to ACI | aml_service/50-deployOnAci.py |
Test Deployment | aml_service/60-AciWebserviceTest.py |
- Your final pipeline should look like below:
- Now we have to set our environment variables. At the top, click Variables.
- In our scripts, we have environment variables for APPID, AZUREML_PASSWORD, RESOURCE_GROUP, SUBSCRIPTION, TENANT_ID, and WORKSPACE_NAME. The APPID and AZUREML_PASSWORD are for the service principal that you created earlier on.
- Click Add and set the name to “APPID” and paste in the application id for the service principal we created.
- Add a variable “AZUREML_PASSWORD” and paste the password that you copied when you created the service principal
- Add a variable for “TENANT_ID” and paste in the Directory ID that you copied above when creating the service principal
- Add environment variable for “RESOURCE_GROUP”, “WORKSPACE_NAME”, and “SUBSCRIPTION”. These are the resource group that your AzureML Workspace is in, the name of your AzureML Workspace, and your subscription ID.
- Your environment variables should look like below
- At the top, click Save & queue, then Save & queue from the dropdown
- On the popup, click Save & queue
- To monitor the build, click on the build number in the top
Your pipeline run should look like the following:
Most devops pipelines have a dev build and a release to production. Treat the build pipeline that you just created as your dev build. Create a release that uses your development pipeline, triggers a user approval for, then pushes the image and trained model to a production release. (hint, in Azure DevOps, explore the Releases tab) https://docs.microsoft.com/en-us/azure/devops/pipelines/release/?view=azure-devops