In Azure, configuring compute instances is an essential step before executing any data science workload for DP-100 exam preparations. This process can be expediently carried out through the terminal. However, before delving into it, let’s understand the Azure Compute instance.
The Azure Compute Instance is an Infrastructure-as-a-Service (IaaS) solution from Azure. It provides virtual machines (VMs) to run apps and develop or test on demand. They deliver on-demand, scalable computing resources by eliminating the need for a tangible hardware infrastructure, promoting flexibility and cost savings.
A. Setting Up Azure CLI
One effective way to configure Compute Instances is by using the Azure Command Line Interface (CLI), a unified tool designed to help you build, manage, and administer Azure resources from the terminal.
To get started with Azure CLI, you’re required to install it into your computer system. Here’s how to get it done on different platforms:
- Ubuntu 20.04 LTS
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- macOS
brew update && brew install azure-cli
- Windows 10
Consider using the Windows 10 Installer: https://aka.ms/installazurecliwindows
After a successful installation, open a new terminal window and run the az login
command to authenticate your account.
az login
B. Creating the Compute Instance
Now, let’s take a step-by-step approach on how to use the terminal to create a compute instance.
Step 1: Decide on the variables you’ll be using throughout this guide. Replace the sample values with your actual values:
myResourceGroup="mres1204"
mySubscription="3392e465-ce06-4dbf-8e03"
myLocation="eastus"
myVmName="myVm805"
Step 2: Set the subscription
az account set --subscription $mySubscription
Step 3: Create a resource group
az group create --name $myResourceGroup --location $myLocation
Step 4: Create a compute instance.
az vm create --resource-group $myResourceGroup --name $myVmName --image UbuntuLTS --generate-ssh-keys
These steps will create a simple Ubuntu Compute Instance in Azure by using the terminal.
C. Managing the Compute Instance
You can also manage the compute instance right from the terminal. This includes actions like starting, stopping, or even deleting the VM. Remember, replace yourVmName
and yourResourceGroup
with actual values.
- Starting the VM:
az vm start --name yourVmName --resource-group yourResourceGroup
- Stopping the VM:
az vm stop --name yourVmName --resource-group yourResourceGroup
- Deleting the VM:
az vm delete --name yourVmName --resource-group yourResourceGroup
Using a terminal to configure and manage Azure Compute Instances provides a compact, scriptable, and highly adaptable environment for managing resources. However, always ensure to use up-to-date, reliable documentation to get the most out of cloud computing in Azure.
Practice Test
True or False: The Azure cloud shell can accomplish terminal specific tasks.
- True
- False
Answer: True
Explanation: Azure cloud shell is an interactive shell environment hosted in Azure and used for managing Azure resources.
You can deploy Azure Machine Learning models to a compute instance. Choose the correct one.
- A. True
- B. False
Answer: B. False
Explanation: Compute instances are not the deployment target for Azure Machine Learning models. They are used primarily for development and testing.
To establish an SSH connection to a VM in Azure, you need to:
- A. Get the public IP address of the VM
- B. Generate a key pair
- C. Both A and B
- D. None of the above
Answer: C. Both A and B
Explanation: You need both the public IP address of the VM and a key pair to establish a secure connection to your VM using SSH.
True or False: The Azure portal allows users to deploy, manage, and delete resources in their Azure account.
- True
- False
Answer: True
Explanation: The Azure portal is a web-based application that can be used to create, manage and remove Azure resources and services.
What needs to be done to start using Azure Machine Learning CLI?
- A. Install Azure CLI
- B. Add the Machine Learning extension to Azure CLI
- C. Both A and B
- D. None of the above
Answer: C. Both A and B
Explanation: To use Azure Machine Learning CLI, first, the Azure CLI needs to be installed, and then the Machine Learning extension for Azure CLI needs to be added.
True or False: You can access Azure Cloud Shell from the Azure portal.
- True
- False
Answer: True
Explanation: Azure Cloud Shell can be accessed directly from the Azure Portal and provides an authenticated, interactive shell for managing Azure resources.
Which of the following commands can be used to list all available extensions in Azure CLI?
- A. az extension list
- B. az extension list-available
- C. az list-extension
- D. None of the above
Answer: B. az extension list-available
Explanation: The command az extension list-available is used to list all available extensions in Azure CLI.
To configure a compute instance using the terminal, the user should be familiar with:
- A. Azure CLI
- B. Bash or Powershell
- C. Azure portal
- D. All of the above
Answer: D. All of the above
Explanation: All these tools can be used to configure and manage compute instances in Azure.
True or False: Azure Cloud Shell automatically authenticates with your Azure account.
- True
- False
Answer: True
Explanation: Azure Cloud Shell uses the account you sign in to Azure portal with, so it is already authenticated.
Where can Azure CLI be run from?
- A. The Azure portal
- B. The local machine
- C. Cloud shell
- D. All of the above
Answer: D. All of the above
Explanation: Azure CLI can run from all of the above-mentioned platforms.
Interview Questions
What are the steps to install the Azure Machine Learning SDK on a Windows computer?
To install the Azure Machine Learning SDK on a Windows computer, you can run the command
pip install azureml-sdk
, and optionally add specific extras as needed.
What command should be used to update the Azure Machine Learning SDK?
To update the Azure Machine Learning SDK, you can use the command
pip install --upgrade azureml-sdk
.
How can you check if the correct versions of the Azure Machine Learning SDK and its dependencies are installed?
You can verify if the correct versions of the Azure Machine Learning SDK and its dependencies are installed by running the command
pip show azureml-sdk
.
What is the command to view all installed Python packages, including the Azure Machine Learning SDK?
The command
pip list
can be used to view all installed Python packages, which includes the Azure Machine Learning SDK if it has been installed.
How do you list the versions of specific Python packages, including the Azure Machine Learning SDK?
Running the command
pip list | grep package_name
(replace
package_name
with the specific package you want to check) will list the versions of the specified Python packages installed, including the Azure Machine Learning SDK.
What command should be used to uninstall the Azure Machine Learning SDK?
To uninstall the Azure Machine Learning SDK, you can use the command
pip uninstall azureml-sdk
.
How can you verify that the Azure Machine Learning SDK has been successfully uninstalled?
You can verify that the Azure Machine Learning SDK has been successfully uninstalled by running the command
pip show azureml-sdk
, which should return an error indicating that the package is not installed.
What are the steps to log in to an Azure subscription using the Azure Machine Learning SDK?
To log in to an Azure subscription using the Azure Machine Learning SDK, you can run the command
az login
in the terminal, and then authenticate using the generated code.
How can you check the version of Azure CLI installed on your system?
The command
az --version
can be used to check the version of Azure CLI installed on your system.
What is the command to generate service principal details for Azure Machine Learning SDK authentication?
The command
az ad sp create-for-rbac --name service_principal_name
(replace
service_principal_name
with a name for the service principal) can be used to generate service principal details for Azure Machine Learning SDK authentication.