Skip to main content

AZ-104 - Administration - Azure CLI and Powershell

Install PowerShell on Windows, Linux, and macOS
How to install the Azure CLI

Commands

 

What is the Azure CLI
  • Its a command-line utility for managing azure resources
  • Crate and manage resources without logging to the azure portal
  • Create scripts to automate tasks

image.png

What is Azure PowerShell
  • Its a set of cmdlets for managing Azure resources
  • Create and manage resource s without logging into the azure portal
  • Create scripts to automate tasks.

image.png

Cloud Shell

First we need to create a Cloud Shell 

image.png

Select Bash or Powershell

image.png

Go to Advanced settings

image.png

Select a random storage account name and a file share name then click on create storage

image.png

if you get this error its more likely your storage account name its already in use, use alphanumeric

image.png

Done, you can switch between Powershell and Bash using the drop down menu on the left

image.png

Here we can run AZ CLI commands

image.png

And here is using the powershell

image.png

We can save objects to variables

image.png

To create a virtual machine from Azure CLI

image.png

PS /home/cesar> get-cloudDrive                                                                                                        

FileShareName      : random1fileshare
FileSharePath      : //random1storage4.file.core.windows.net/random1fileshare
MountPoint         : /home/cesar/clouddrive
Name               : random1storage4
ResourceGroupName  : DefaultResourceGroup-CUS
StorageAccountName : random1storage4
SubscriptionId     : 33d9a849-c6f5-455d-b9e4-ef89b317fcec

PS /home/cesar> get-azresource | format-Table              

Name                                                      ResourceGroupName        ResourceType                             Location
----                                                      -----------------        ------------                             --------
DefaultWorkspace-33d9a849-c6f5-455d-b9e4-ef89b317fcec-CUS DefaultResourceGroup-CUS Microsoft.OperationalInsights/workspaces centralus
random1storage4                                           DefaultResourceGroup-CUS Microsoft.Storage/storageAccounts        eastus
NetworkWatcher_eastus                                     NetworkWatcherRG         Microsoft.Network/networkWatchers        eastus

PS /home/cesar>