AZ-104 Exam EP 11: Azure PowerShell & CLI
Table of Contents
Introduction
This tutorial will guide you through the essentials of using Azure PowerShell and Azure CLI as part of your preparation for the AZ-104 Azure Administrator exam. Understanding these tools is crucial for managing Azure resources effectively. This step-by-step guide will make it easier for you to get started with both Azure PowerShell and CLI.
Step 1: Understanding Azure PowerShell
Azure PowerShell is a set of modules that allow you to manage Azure resources directly from the command line. It is particularly useful for automating tasks and managing resources at scale.
Key Features of Azure PowerShell
- Automation: Automate repetitive tasks with scripts.
- Resource Management: Manage Azure resources like virtual machines, storage accounts, and networks.
- Ease of Use: Use familiar PowerShell commands and syntax.
Practical Tips
- Install the Azure PowerShell module using the following command:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
- Always update to the latest version for new features and security fixes.
Step 2: Working with Azure PowerShell
To demonstrate the use of Azure PowerShell, follow these steps:
Steps to Get Started
- Open PowerShell: Launch PowerShell on your machine.
- Log in to Azure: Authenticate your session with Azure using:
Connect-AzAccount
- List Subscriptions: Check your subscriptions with:
Get-AzSubscription
- Select a Subscription: Choose the active subscription you want to work with:
Select-AzSubscription -SubscriptionId "your-subscription-id"
- Manage Resources: Use commands like
New-AzVM
,Get-AzResource
, andRemove-AzResource
to create, list, and delete resources respectively.
Step 3: Understanding Azure CLI
Azure CLI is a command-line tool designed for managing Azure resources. It is cross-platform, making it accessible on Windows, macOS, and Linux.
Key Features of Azure CLI
- Simplicity: Easy to use with straightforward commands.
- Cross-Platform: Works on any operating system.
- Integration: Integrates well with scripts and automation tools.
Practical Tips
- Install Azure CLI by following the instructions on the Azure CLI Installation Guide.
- Use the command
az --version
to verify the installation.
Step 4: Working with Azure CLI
To effectively use Azure CLI, follow these steps:
Steps to Get Started
- Open Command Prompt or Terminal: Depending on your OS, launch your terminal.
- Log in to Azure: Authenticate your session with:
az login
- List Subscriptions: View your subscriptions with:
az account list --output table
- Select a Subscription: Set the active subscription:
az account set --subscription "your-subscription-name"
- Manage Resources: Use commands such as
az vm create
,az resource list
, andaz resource delete
for managing resources.
Conclusion
By mastering Azure PowerShell and Azure CLI, you will enhance your ability to manage Azure resources effectively. This tutorial provided a clear pathway to getting started with both tools, including installation, authentication, and basic commands.
Next Steps
- Practice using both Azure PowerShell and CLI to solidify your understanding.
- Explore additional resources and documentation to deepen your knowledge.
- Consider setting up a sandbox environment in Azure for hands-on experience.