Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Azure Machine Learning Engineering

You're reading from   Azure Machine Learning Engineering Deploy, fine-tune, and optimize ML models using Microsoft Azure

Arrow left icon
Product type Paperback
Published in Jan 2023
Publisher Packt
ISBN-13 9781803239309
Length 362 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (4):
Arrow left icon
Balamurugan Balakreshnan Balamurugan Balakreshnan
Author Profile Icon Balamurugan Balakreshnan
Balamurugan Balakreshnan
Dennis Michael Sawyers Dennis Michael Sawyers
Author Profile Icon Dennis Michael Sawyers
Dennis Michael Sawyers
Sina Fakhraee Ph.D Sina Fakhraee Ph.D
Author Profile Icon Sina Fakhraee Ph.D
Sina Fakhraee Ph.D
Megan Masanz Megan Masanz
Author Profile Icon Megan Masanz
Megan Masanz
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Part 1: Training and Tuning Models with the Azure Machine Learning Service
2. Chapter 1: Introducing the Azure Machine Learning Service FREE CHAPTER 3. Chapter 2: Working with Data in AMLS 4. Chapter 3: Training Machine Learning Models in AMLS 5. Chapter 4: Tuning Your Models with AMLS 6. Chapter 5: Azure Automated Machine Learning 7. Part 2: Deploying and Explaining Models in AMLS
8. Chapter 6: Deploying ML Models for Real-Time Inferencing 9. Chapter 7: Deploying ML Models for Batch Scoring 10. Chapter 8: Responsible AI 11. Chapter 9: Productionizing Your Workload with MLOps 12. Part 3: Productionizing Your Workload with MLOps
13. Chapter 10: Using Deep Learning in Azure Machine Learning 14. Chapter 11: Using Distributed Training in AMLS 15. Index 16. Other Books You May Enjoy

Building your first AMLS workspace

Within Azure, there are numerous ways to create Azure resources. The most common method is through the Azure portal, a web interface that allows you to create resources through a GUI. To automate the creation of resources, users can leverage the Azure CLI with the ml extension (V2), which provides you with a familiar terminal to automate deployment. You can also create resources using ARM templates. Both the CLI and the ARM templates provide an automatable, repeatable process to create resources in Azure.

In the upcoming subsections, we will first create an AMLS workspace through the web portal. After you have mastered this task, you will also create another workspace via the Azure CLI. Once you understand how the CLI works, you will create an ARM template and use it to deploy a third workspace. After learning about all three deployment methods, you will delete all excess resources before moving on to the next section; leaving excess resources up and running will cost you money, so be careful.

Creating an AMLS workspace through the Azure portal

Using the portal to create an AMLS workspace is the easiest, most straightforward approach. Through the GUI, you create a resource group, a container to hold multiple resources, along with your AMLS workspace and all its components. To create a workspace, navigate to https://portal.azure.com and follow these steps:

  1. Navigate to https://portal.azure.com and type Azure Machine Learning into the search box as shown in Figure 1.1 and press Enter:

Figure 1.1 – Selecting resource groups

Figure 1.1 – Selecting resource groups

  1. On the top left of the Azure portal, select the + Create option shown in Figure 1.2:
Figure 1.2 – Creating an AML workspace

Figure 1.2 – Creating an AML workspace

Selecting the + Create option will bring up the Basics tab as shown here:

Figure 1.3 – Filling in the corresponding fields to create the ML workspace

Figure 1.3 – Filling in the corresponding fields to create the ML workspace

  1. In the Basics tab shown in Figure 1.3 for creating your AML workspace, populate the following values:
    1. Subscription: The Azure subscription you would like to deploy your resource.
    2. Resource group: Click on Create new and enter a name for a resource group. In Azure, resource groups can be thought of as folder, or container that holds resources for a particular solution. As we deploy the AMLS workspace, the resources will be deployed into this resource group to ensure we can easily delete the resources after performing this exercise.
    3. Workspace name: The name of the AMLS workspace resource.
    4. The rest of the options are the default, and you can click on the Review + create button.
  2. This will cause validation to occur – once the information has been validated, click on the + Create button to deploy your resources.
  3. It usually takes a few minutes for the workspace to be created. Once the deployment is completed, click on Go to resource in the Azure portal and then click on Launch studio to go to the AMLS workspace.

You are now on the landing page for AMLS as shown in Figure 1.4:

Figure 1.4 – AMLS

Figure 1.4 – AMLS

Congratulations! You have now successfully built your first AMLS workspace. While you can start by loading in data right now, take the time to walk through the next section to learn how to create it via code.

Creating an AMLS workspace through the Azure CLI

For people who prefer a code-first approach to creating resources, the Azure CLI is the perfect fit. At the time of writing, the AML CLI v2 is the most up-to-date extension for the Azure CLI available. While leveraging the Azure CLI v2, assets are defined by leveraging a YAML file, as we will see in later chapters.

Note

The Azure CLI v2 uses commands that follow a format of az ml <noun> <verb> <options>.

To create an AMLS workspace via the Azure CLI ml extension (v2), follow these steps:

  1. You need to install the Azure CLI from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli.
  2. Find your subscription ID. In the Azure portal in the search box, you can type Subscriptions, and bring up a list of Azure subscriptions and the ID of the subscriptions. For the subscription that you would like to use, copy the Subscription ID information to use it with the CLI.

Here’s a view of Subscriptions within the Azure portal:

Figure 1.5 – Azure subscription list

Figure 1.5 – Azure subscription list

  1. Launch your command-line interpreter (CLI) based on your OS – for example, Command Prompt (CMD) or Windows Powershell (Windows PS) – and check your version of the Azure CLI by running the following command:
    az version

Note

You will need to have a version of the Azure CLI that is greater than 2.15.0 to leverage the ml extension.

  1. You will need to remove old extensions if they are installed for your CLI to work properly. You can remove the old ml extensions by running the following commands:
    az extension remove -n azure-cli-ml
    az extension remove -n ml
  2. To install the ml extension, run the following command:
    az extension add -n ml -y
  3. Now, let’s connect to your subscription in Azure through the Azure CLI by running the following command here, replacing xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with the Subscription ID information you found in Figure 1.5:
    az login
    az account set --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  4. Create a resource group by running the following command. Please note that rg_name is an example name for the resource group, just as aml-ws is an example name for an AML workspace:
    az group create --name aml-dev-rg  --location eastus2
  5. Create an AML workspace by running the following command, noting that eastus2 is the Azure region in which we will deploy this AML workspace:
    az ml workspace create -n aml-ws -g aml-dev-rg -l eastus2

You have now created an AMLS workspace with the Azure CLI ml extension and through the portal. There’s one additional way to create an AMLS workspace that’s commonly used, ARM templates, which we will take a look at next.

Creating an AMLS workspace with ARM templates

ARM templates can be challenging to write, but they provide you with a way to easily automate and parameterize the creation of Azure resources. In this section, you will first write a simple ARM template to build an AMLS workspace and then deploy your template using the Azure CLI. To do so, take the following steps:

  1. An ARM template can be downloaded from GitHub and is found here: https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.machinelearningservices/machine-learning-workspace/azuredeploy.json.

This template creates the following Azure services:

  • Azure Storage Account
  • Azure Key Vault
  • Azure Application Insights
  • Azure Container Registry
  • An AML workspace

The example template has three required parameters:

  • environment, where the resources will be created
  • name, which is the name that we are giving to the AMLS workspace
  • location, the Azure Region the resource will be deployed to
  1. To deploy your template, you have to create a resource group first as follows:
    az group create --name rg_name --location eastus2
  2. Make sure your command prompt is opened to the location to which you downloaded the azuredeploy.json file, and run the following command:
    az deployment group create --name "exampledeployment" --resource-group "rg_name" --template-file "azuredeploy.json" --parameters name="uniquename" environment="dev" location="eastus2"

It will take a few minutes for the workspace to be created.

We have covered a lot of information so far, whether creating an AMLS workspace using the portal, the CLI, or now using ARM templates. In the next section, we will show you how to navigate the workspace, often referred to as the studio.

You have been reading a chapter from
Azure Machine Learning Engineering
Published in: Jan 2023
Publisher: Packt
ISBN-13: 9781803239309
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime