The first step of preparing a machine learning project in Azure is to prepare your Azure Machine Learning workspace, which provides all the tools, components, triggers, and actions you need to develop, train, deploy, and monitor your machine learning model. In this article of this series, I will talk about workspaces, Azure Machine Learning workspace, how to prepare a machine learning workspace, components you get within an ML workspace, and security, monitoring, and cost management features of a workspace.
What is a Workspace?
In Azure workspace, we get all the components of a project where multiple people can collaborate using different technical tools available within the workspace. It is a recommended best practice to create one workspace per project to monitor the cost, security, and accessibility better. We can have multiple projects in a single workspace and multiple people working on a single workspace as well, but it is easier to manage all the resources of a single workspace if they all belong to one project.
Machine Learning Workspace
In an Azure Machine Learning workspace, multiple data scientists, analysts, and collaborators work on a single machine learning project from a single place. Azure Machine Learning workspace provides several types of compute support, machine learning experiment management options, jobs pipeline, dataset management, data source connections, secured container handling, model environment preparation, and scalable inferencing options. To begin, we’ll need an Azure account, an Azure subscription, and a resource group to create a workspace. We can either create a new resource group or an existing one for our workspace.
We can create a machine learning workspace in Azure in multiple ways.
- Using Azure web portal
- Using Azure Machine Learning studio
- Using Azure Machine Learning Python SDK
- Using Azure CLI extension on the command line
- Using VS Code extension for Azure Machine Learning
In this article, we will look at the Azure web portal option to create our workspace.
Creating an Azure Machine Learning Workspace
To create an Azure Machine Learning workspace from the web portal, first, we need to click Create a resource. In the search box, look for Azure machine learning, and you will see all the available options under the search bar.
Figure 1. Azure Machine Learning workspace creation | Used with permission from Microsoft.
ALT: Screenshot in Microsoft Azure to create a resource and filter to Azure Machine Learning.
Figure 1 shows the available options. Select the first one, Azure Machine Learning, and click Create. On the next page, you can review your choice, usage information, available plans, etc.
Figure 2. Azure Machine Learning service overview. | Used with permission from Microsoft.
ALT: Screenshot of the page in Microsoft Marketplace where you confirm choices before you create an Azure Machine Learning workspace.
From here, simply click Create to go to the next page of creating azure machine learning workspace.
Figure 3. Azure Machine Learning workspace creation detail. | Used with permission from Microsoft.
ALT: Here you will see the detailed options to create your Azure Machine Learning workspace. First, you need to select your subscription; you can select one from the multiple available options from the drop-down menu.
You can choose an existing resource group for this workspace or click “Create New” to create a new resource group for this machine learning workspace. Right after that, you need to complete the workspace detail. You need to select a unique workspace name, region, storage account, key vault, application insights, and container registry.
For storage account, key vault, and Application Insights, you can choose an existing key vault or storage account if you have already set up those components within this resource group. But you cannot select components of a different resource group here. If your resource group is new, then you will need to create a new key vault, storage account, and application insights here. The storage account security keys will be stored in the vault. All the artifacts generated during your machine learning development process will be, by default, stored in the storage account of this resource group.
You can click Networking if you already have a virtual network deployed to peer your new machine learning workspace in order to make your overall development more secure. In this case, I clicked Review + Create to create and deploy the workspace.
Figure 4. Deployment page of Azure Machine Learning workspace | Used with permission from Microsoft.
ALT: Once the workspace is deployed, you will see Figure 4, although it may take a few seconds to complete the deployment process. From the deployment page, click the button labeled Go to resource.
Figure 5. Azure Machine Learning resource page | Used with permission from Microsoft.
ALT: You should now see Figure 5, where you can review the resources of your Azure Machine Learning workspace. Here, you will see your resource information, location, region, subscription ID, storage account, and application insights information. Based on your requirements, it is a best practice to add the right tag in your workspace or in your Azure services; this will help you monitor the costs of projects with certain tags.
If you want multiple team members to collaborate on a single project under one machine learning workspace, you need to click Access Control (IAM) from the left panel and add a new contributor/owner following the team’s needs. All the user access management can be done from the access control (IAM) page, along with access to the storage account.
Now, to open Azure Machine Learning Studio from the workspace, simply click the studio web URL, and this will open a new tab to take you to the Azure Machine Learning Studio portal.
Figure 6. Azure Machine Learning Studio portal | Used with permission from Microsoft.
ALT: The Azure Machine Learning studio portal gives you all the tools and components you will need to create your machine learning experience, compute for your machine learning experiment, deploy processes, automate jobs, etc.
Components Created and Provisioned for You in Your Azure Machine Learning Workspace.
Let's go back to the resource group in the Azure portal to see all the components that have been provisioned along with the Azure machine learning workspace.
Figure 7. Components within the resource group for Azure Machine Learning workspace | Used with permission from Microsoft.
ALT: Right after creating the workspace in an empty resource group, if you go back to resource group resources, you will see multiple services, but you have provisioned only Azure Machine Learning. The reason is, that when you create an Azure Machine Learning workspace, the resources listed below are automatically created for you within the same resource group.
Application Insights
Azure Application Insights is used to collect monitoring and diagnostics data. If you deploy any endpoint after model training, Application Insights will log the number of successful request responses handled by your deployed model, the number of failed requests, and the runtime information. You can see the data under the Application Insights section. If you delete the Application Insights service from your workspace, you cannot re-create it again unless you create a new workspace.
Storage Account
A storage account created with Azure Machine Learning Workspace stores all the data sets uploaded by users to Azure Machine Learning Studio. During the experiment phase, all the data artifacts, images, screenshots, and metrics that you create for your machine learning project will be stored in this storage account by default. Even the notebooks created for writing codes will be stored in the storage account as well.
Key Vault
Azure created an Azure Key Vault during the creation of the Azure Machine Learning workspace. The key vault is used to store all the secret keys and tokens of data stores, data connections, and compute targets. This gives an extra level of security to your machine-learning project.
Azure ML Workspace
This is your Azure Machine Learning Studio, provisioned under this workspace, which gives you all the tools you need for this machine learning project.
Components in Machine Learning Workspace
An Azure Machine Learning workspace (Figure 6) contains many components that help us throughout our machine learning life cycle to complete our AI application development loop.
Model Development
Within the Azure Machine Learning workspace, you can train and develop our machine learning model in three ways.
- Jupyter Notebooks (https://learn.microsoft.com/en-us/azure/machine-learning/how-to-run-jupyter-notebooks?view=azureml-api-2)
- Automated machine learning (https://learn.microsoft.com/en-us/azure/machine-learning/concept-automated-ml?view=azureml-api-2)
- Designer (https://learn.microsoft.com/en-us/azure/machine-learning/concept-designer?view=azureml-api-2)
In this series, you will only use Azure notebooks for your experiments. Azure notebooks use the underlying technology of Jupyter notebooks, where one can work on a machine learning project following a modularized approach. Through automated machine learning projects, all you need to do is select our dataset and some configurations, and everything else is handled by the backend. Under the machine learning designer, all the machine learning development components are available as drag-and-drop modules. All you need to do is drop them in the canvas panel and configure them based on your needs.
Data Source
You can connect different Azure data sources like blob storage, SQL, ADLS, and cosmosDB or upload a tabular-based file/data asset into the machine learning studio portal. Lots of data connectors and data asset management options are available in the machine learning studio. I will cover this topic in article six, where I’ll show a step-by-step demo of data connections.
Jobs
Jobs are scheduled machine learning model runs. If you have developed a training pipeline where every week your experiment collects data from the last seven days from different data sources, and then prepares a complete dataset, and then conducts a machine learning model re-training process, in that case, this run is a scheduled job.
Reusable Workflow Pipelines
You can build pipelines with multiple actions (training, resource maintenance, re-training process, etc.), and that collection of actions is called workflow pipelines in Azure Machine Learning. Once you build one workflow pipeline, you can re-use this pipeline in other experiments and these pipelines are used for both model training and re-training.
Environments and Model Registration
Once a model is trained, you need to deploy this model to make predictions in production. During the training process, if you have used multiple libraries to train the model, you should create a docker container with those libraries so that you can conduct the model prediction process properly. The environment you need to create to run the trained model is called a machine-learning model environment. A YAML file lists the necessary libraries represented in the environment of a model training.
Once an experiment is done, you take the machine learning model to validate and test. You need to register a docker container with the right environment along with the model scoring file and the trained model file, and then register them in a container registry so that you can deploy that container as a container instance in the future during the testing process.
Model Deployment
Azure machine learning provides us with two options to deploy our trained machine learning model.
- Azure container instance (ACI): a single instance of the model used for testing purposes.
- Azure Kubernetes Services (AKS): this provides options to deploy our model in multiple pods/instances for scalability, mostly for QA/production purposes.
Managed Compute
Compute is one of the most important parts of machine learning model training, testing, and deployment. In Azure Machine Learning, you may select multiple types of compute, choosing both CPU- and GPU-based machines. You can select a single instance of a machine or a cluster of multiple machines for bigger machine-learning jobs. You can configure the complete, scalable machine learning production environment from the workspace with the right number of compute instances.
Machine Learning Workspace Interaction
You can use the machine learning workspace components in four ways.
- Azure Machine Learning Studio (ML studio)
- Python SDK
- Azure ML CLI
- VS Code Extension
You can directly configure jobs, create experiments, and connect data sources from the ML studio portal. Alternatively, you can use the Python SDK, the command line-based ML CLI, or a Visual Studio Code extension of Azure Machine Learning workspace to use ML components. In this series, I will mostly use the ML Studio web portal, and in some cases, I will use Python SDK to configure some machine learning jobs.
Azure ML Workspace Cost
Monitoring cost is particularly important for a machine learning project as you can easily spend a lot of money if you configure one or more machines wrong and keep them running for hours and hours. I think the best way to monitor the cost of a workspace is to go back to the resource group, select the cost analysis option from the cost management, and see which component is running, which resource is costing the most, and what is the forecasted cost for the month. You can even configure different types of cost alerts from the cost alerts options under cost management, where whenever the cost crosses a certain threshold, Azure will send you an email alert mentioning the numbers.
Figure 8. Cost analysis of Azure Machine Learning workspace. | Used with permission from Microsoft.
ALT: In this article, I have mostly reviewed Azure Machine Learning workspace, and I discussed how to create an ML workspace, different components of ML workspace, and four ways to interact with ML workspace components. This is the first step to preparing your machine learning environment. In my next article, I will talk about Azure Machine Learning compute details for both model training and deployment.