Lab CLIPw SH Cloud Shell
Lab CLIPw SH Cloud Shell
In this lab you will use the Azure CLI and Azure PowerShell commandlets to manage
Azure resources. You will run the commands from the Azure Cloud Shell, which you
will open from the Azure Portal. You will list resources and create a resource using both
the CLI and PowerShell.
Note: You do not need experience scripting nor do you even need experience using the
command line to complete this lab. All of the commands that you need are in the
solution section. If you are new to scripting, read through the tasks and go directly to
the solution and follow the steps there.
Note: The commands in this lab to create environment variables using the CLI and
PowerShell are more advanced. They use techniques in bash shell and PowerShell that
are beyond this course. These commands are given to you and you do not need to spend
time trying to figure them out.
Lab Objectives
Tasks
Tasks
Log into the Azure portal using the provided lab credentials.
Open Cloud Shell from the Azure Portal. Use the bash shell and create a new storage
account in your resource group for the Cloud Shell storage.
Task 2. Retrieve resource information by using the Azure CLI
For this task, you will use the Azure CLI to retrieve information on services and
resources in Azure. You will start by listing the command groups available in the CLI,
then use the CLI to return information on subscriptions that you have access to. You
will then use the CLI to list resource groups that you have access to. Finally, you will
display information about a virtual machine. To complete this task:
Execute the following command to discover the top level groups of commands for the
Azure CLI:
az help
Execute the following command to view the details of a virtual machine named lab-vm
in the resource group identified by the $rg environment variable.
For this task you will use the Azure CLI to create a Storage Account in your resource
group and region. To complete this task:
Execute the following command to store the region of your resource group in an
environment variable named location:
Setting Value
Resource
$rg
group
Setting Value
Location $location
Note: The name must be a globally unique combination of lower case letters and
numbers.
Use the Azure CLI to verify that the Storage Account was created.
For this task, you will load PowerShell in Cloud Shell and retrieve information on
services and resources in Azure. You will start by using an Azure PowerShell
commandlet to return information on subscriptions that you have access to. You will
then use a commandlet to list resource groups that you have access to. Finally, you will
display information about a virtual machine. To complete this task:
Execute the following command to start Powershell in your Cloud Shell session:
pwsh
Execute the following commandlet to list the commandlets for Azure subscriptions:
Use the Azure PowerShell commandlet to list the Azure subscriptions in tabular format.
List the resource groups that you have access to in tabular format.
Execute the following to create an environment variable with the name of your resource
group:
$rg=(Get-AzResourceGroup)[0].ResourceGroupName
Execute the following to create an object that represents your virtual machine:
$vm
Execute the following to display OS (operating system) information for your virtual
machine:
$vm.OSProfile
For this task you will use the Azure PowerShell commandlets to create a Storage
Account in your resource group and region. To complete this task:
Execute the following to store the region of your resource group in an environment
variable named location:
$location=(Get-AzResourceGroup)[0].Location
Setting Value
Resource
$rg
group
Location $location
Solutions
Task 0 Solution: Log in to the Azure portal with your lab credentials
Select a region to run your lab in.
Choose the Start lab button and then choose Open lab. On the next page, agree to the
terms and conditions and then choose Continue.
You will be presented with access credentials as shown in the following example. Open
the Azure Portal Login link in a new private window.
The URL will take you to the Microsoft Azure sign-in page. Sign in using the
Username you were provided with and choose Next.
Enter the password you were provided with and choose Sign in. If you're prompted to
save the password, choose Not Now.
You will be redirected to your resource group in the Azure portal.
portal.
Select Bash on the Welcome to Azure Cloud Shell prompt.
Next you will use the intrinsic help capabilities of the Azure CLI to find commands to
list subscriptions, resource groups, and virtual machines. To complete this task:
Execute the following command to discover the top level groups of commands for the
Azure CLI:
az help
Execute the following command to list the commands in the account group:
az account --help
Execute the following command to find out how to list Azure subscriptions:
Execute the following command to list the Azure subscriptions in tabular format:
Execute the following command to learn how to list the resource groups that you have
access to:
Execute the following command to create an environment variable with the name of
your resource group:
Execute the following command to learn how to show the details of a virtual machine:
az vm show --help
Execute the following command to view the details of your virtual machine:
Execute the following command to list the commands for Storage Accounts:
Execute the following command to create a storage account. Replace <unique name>
with a unique name consisting of lower case letters and numbers:
Execute the following command to verify that your storage account was created:
pwsh
Execute the following commandlet to list the commandlets for Azure subscriptions:
Get-AzSubscription | Format-Table
Execute the following to learn how to list the resource groups that you have access to:
List the resource groups that you have access to in tabular format
Get-AzResourceGroup | Format-Table
Execute the following to create an environment variable with the name of your resource
group:
$rg=(Get-AzResourceGroup)[0].ResourceGroupName
Execute the following to learn how to show the details of a virtual machine:
Execute the following to create an object that represents your virtual machine:
Execute the following to display general information for your virtual machine:
$vm
Execute the following to display OS (operating system) information for your virtual
machine:
$vm.OSProfile
$location=(Get-AzResourceGroup)[0].Location
Execute the following command to list the commandlets for Storage Accounts:
Execute the following commandlet to create a storage account. Replace <unique name>
with a unique name consisting of lower case letters and numbers:
Execute the following to verify that your storage account was created:
Get-AzStorageAccount | Format-Table