☁️
CTHFM: Azure
  • Welcome
  • Getting Started
    • Account Setup
      • Account Creation Instructions
  • Azure Fundamentals
    • Azure Fundamentals Overview
      • Azure Documentation
      • Azure Entra
      • Azure Hierarchy
      • Identities
      • Azure Entra Roles
      • Azure RBAC
      • Azure Licensing Overview
        • Azure Entra ID Premium Licenses Comparison
      • Azure Shared Responsibility Model
      • Azure Frameworks
      • Azure Security Services
      • Conditional Access Policies
        • How Conditional Access Policies Work
        • Benefits of Conditional Access
        • Best Practices for Conditional Access
        • Conditions for Conditional Access
        • Conditional Access Controls
        • Sign-In Risk and Identity Protection
        • Conditional Access Session Control
        • Name Locations IP Location
      • Azure Quotas
      • Azure Tokens
        • Access Tokens
        • ID Tokens
        • Refresh Tokens
          • Invalidate Refresh Tokens
        • Primary Refresh Tokens
        • Continuous Access Evaluation (CAE)
        • Token Protection: Conditional Access (Public Preview)
  • Azure CLI
    • Introduction to Azure CLI
    • Installing Azure CLI
    • CLI Commands
    • Resource Group Management
    • Creating and Managing Resources with Azure CLI
    • Managing IAM
    • Azure CLI Automation
    • Monitoring and Troubleshooting in Azure CLI
    • Azure CLI Overview
      • Azure CLI: Linux
      • Azure CLI: Windows
      • Azure CLI: MacOS
  • KQL
    • KQL Overview
      • KQL Introduction
      • Data Types
      • Quick Reference
      • Render
      • Basic Queries
  • Powershell
    • PowerShell for Azure
      • Powershell Documentation
      • Powershell Basics
      • Understanding Powershell Variables
      • Understanding Cmdlets
      • Powershell Console & ISE
      • Powershell: Entra Module
        • Module Reference & Getting Started
      • Powershell: Azure Module
        • Installation Instructions
        • Powershell Azure CLI: Windows
        • Powershell Azure CLI: Linux
        • Powershell Azure CLI: MacOS
        • Example Azure Cmdlets
  • Bicep
    • Bicep File Structure
    • Variable Types
  • Azure Logging References
    • Logging
      • Log Retention Strategies
      • Azure Log Types
      • Azure Activity Logs
        • Administrative Event Schema
        • Service Health Notification Schema
        • Resource Health
        • Alert Category
        • Autoscale
        • Security
        • Recommendation
        • Policy
      • Entra ID Logging
        • Identity Based Logs
          • Audit Logs
          • Sign-In Logs
            • AADNonInteractiveUserSignInLogs
            • AADManagedIdentitySignInLogs
            • AADServicePrincipalSignInLogs
            • First Party Sign-In Activity
          • Provisioning Logs (AADProvisioningLogs)
          • Microsoft Graph Activity
          • Identity Protection
            • Risk Detections
            • AADRiskyServicePrincipals
            • AADRiskyUsers
            • AADUserRiskEvents
            • AADServicePrincipalRiskEvents
        • Additional Entra ID Logs
      • Azure Key Vault
        • Azure Key Vault Logging Overview
      • Network Watcher
        • RBAC Permissions
        • Flow Log Types
          • NSG Flow Log Schema
          • VNET Flow Log Schema
        • Enabling Logs
          • NSG Flow Logs
          • VNET Flow Logs
        • Packet Capture
          • Packet Capture: VM
          • Packet Capture: Scale Sets
      • Compute Resources
        • Azure Monitor Agent
        • VM Insights
          • VM Insights Tables
      • Storage Accounts
        • Storage Account Logging
          • File
            • Enable StorageFileLogs
            • StorageFileLogs
          • Blob
            • Enable Blob Logging
            • StorageBlobLogs
          • Queue
            • Enable Queue Logging
            • StorageQueueLogs Table
          • Table
            • Enable Table Logging
            • StorageTableLogs Table
      • Azure App Service
        • Log Types
        • Enabling Logging
      • Azure Monitor
        • Resource Logs
          • Resource Log Top Level Documentation
        • Log Analytics Workspace
          • Setup
        • Workbooks
        • Dashboards
        • Alerts
        • Azure Monitor Documentation
      • Defender for Cloud
      • Intune
      • Sysmon
      • Purview Audit Log Schema
      • Kubernetes Audit Log (AKS)
  • Threat Hunting
    • Threat Hunting in Azure
      • Threat Hunting Introduction
      • Threat Hunting Process
        • Hypothesis Generation
        • Investigation
        • Identification
        • Resolution & Follow Up
      • Pyramid of Pain
      • Azure Threat Hunting Ideas
      • Hands On Threat Hunting Examples
      • OSINT Feeds
  • Sigma
    • Sigma Rule Structure
  • Microsoft Defender TI
    • Microsoft Defender Threat Intelligence
      • Data Sets
      • Reputational Scoring
      • Analyst Insights
      • Microsoft Defender TI: Copilot Integration
  • MITRE Att&ck
    • MITRE Att&ck
      • MITRE Att&ck Concepts
      • MITRE Data Sources
      • MITRE Att&ck Mitigations
      • MITRE Att&ck: Azure
        • MITRE Att&CK: Azure Security Control Mapping
  • Microsoft Resources
    • Microsoft Incident Response Ninja Hub
    • Microsoft Defender XDR Ninja Hub
  • Azure Threat Research Matrix (ATRM)
  • Security Research & Resources
    • Azure Goat
    • Azure Security Research
      • Azure Related CVEs
  • Defender XDR
    • Defender XDR Overview
    • Defender XDR Licensing
    • Defender XDR Default Retention
    • Defender XDR Advanced Hunting Table Schemas
    • Automated Response Requirements
    • Supported Response Actions
  • Azure Sentinel
    • Sentinel Overview
    • Azure Sentinel Deployments
    • Supported Data
    • Workbook, Playbook, Notebook Comparison
    • Sentinel Workbooks
    • Entities
    • User and Entity Behavior Analytics
    • Anomaly Detection
    • Mult-Stage Attack Detection
    • Sentinel: Az CLI
  • Microsoft Defender
    • Microsoft Defender for Cloud References
    • Defender for Cloud: Az CLI
  • Azure Policy
    • Azure Policy
    • Azure Policy Components
    • Azure Policy Rules
    • Scope Azure Policy
    • Policy Assignments
    • Policy Effect
    • Initiative Definition
    • Policy Parameters
    • Remediation Task Structure
    • Use Cases for Azure Policy
    • Azure Policy: Az CLI
  • Intune
    • Intune Overview
    • Intune Licensing
    • Intune API Permission Scopes
    • Intune Sample Script Resources
  • Intune Logging
    • Configure Logging
    • Logging Schema References
    • Intune Queries and Resources
  • Windows Host Security
    • Windows System Architecture and OS Fundamentals
    • SysInternals
    • Basic vs Advanced Security Auditing
    • Sysmon
  • Adversary Emulation
    • AzureHound
    • AADInternals
      • Install
    • RoadTools
      • Install
    • Oh365UserFinder
    • GraphRunner
  • Incident Response
    • Incident Response
      • Azure IR Program Development Cheat Sheet
      • Azure IR Playbooks (MS Guidance)
      • Ransomware (MS Guidance)
  • Automation
    • Automation Overview
    • Logic Apps
      • How Logic Apps Work
      • Logic App Types
      • Triggers
      • Connectors
      • Conditional Logic and Control Flow
      • APIs in Logic Apps
      • Handling Large Workflows with Stateful Logic Apps
      • External Service Integration
      • Securing, Managing, and Scaling Azure Logic Apps
      • Logic Apps: Az CLI
  • Packet Analysis
    • Wireshark Cheatsheet
    • TShark Cheatsheet
    • TCPDUMP Cheatsheet
    • Protocol Analysis Basics
    • HTTP Response Code Cheatsheet
    • RFC Protocol Mappings
    • PCAP Acquisition
  • Detection Lab
    • Detection Lab Introduction
    • Account Creation Instructions
    • Enable MFA Within Azure Tenant
    • Create an Azure Admin With Cloud Shell
    • Setup and Install Instructions
  • VSCode and Code Setup
  • Deploying Code
  • Enabling Logs for Log Analytics Workspace
  • Logging Into Windows VM
  • Verifying Logs in Log Analytics Workspace
  • Creating Detections: Azure Monitor
  • Cost Management: Billing Alarms
Powered by GitBook
On this page
  • 5.1 Creating Virtual Machines (VMs)
  • πŸ”Œ 5.2 Connect to the VM
  • πŸ›‘ 5.3 Managing a VM (Start, Stop, Restart, Delete)
  • πŸ“¦ 5.4 Creating Storage Accounts
  • 🌐 5.5 Creating Basic Networking Components
  • 🧹 5.6 Cleaning Up Resources
  • πŸ“ Module 5 Summary
  1. Azure CLI

Creating and Managing Resources with Azure CLI

5.1 Creating Virtual Machines (VMs)

Virtual Machines (VMs) are one of the most common resources you'll deploy in Azure.


πŸ› οΈ Create a Linux VM

bashCopyEditaz vm create \
  --resource-group myResourceGroup \
  --name myLinuxVM \
  --image UbuntuLTS \
  --admin-username azureuser \
  --generate-ssh-keys
Parameter
Purpose

--resource-group

Where the VM will be created

--name

Name of the VM

--image

OS image (Ubuntu, Windows, etc.)

--admin-username

Login username

--generate-ssh-keys

Automatically create SSH keys

βœ… This command will create:

  • VM

  • Public IP

  • NIC (Network Interface)

  • OS Disk

  • Virtual Network (if needed)


πŸ–₯️ Create a Windows VM

bashCopyEditaz vm create \
  --resource-group myResourceGroup \
  --name myWindowsVM \
  --image Win2019Datacenter \
  --admin-username azureuser \
  --admin-password YourP@ssword123

⚠️ Tip: Passwords must meet Azure’s complexity requirements!


πŸ”Œ 5.2 Connect to the VM

Get the public IP address of the VM:

bashCopyEditaz vm list-ip-addresses --name myLinuxVM --output table

Connect to a Linux VM:

bashCopyEditssh azureuser@<public-ip-address>

Connect to a Windows VM (RDP):

  1. Open Remote Desktop Connection.

  2. Enter the public IP.

  3. Login with the username/password.

βœ… Now you're inside your VM!


πŸ›‘ 5.3 Managing a VM (Start, Stop, Restart, Delete)

Action
Command

Stop a VM

az vm stop --name myVM --resource-group myResourceGroup

Start a VM

az vm start --name myVM --resource-group myResourceGroup

Restart a VM

az vm restart --name myVM --resource-group myResourceGroup

Delete a VM

az vm delete --name myVM --resource-group myResourceGroup

βœ… Important: Stopping a VM does not delete it β€” it just stops billing for compute time (but storage costs remain).


πŸ“¦ 5.4 Creating Storage Accounts

Storage Accounts provide scalable, durable cloud storage for:

  • Blobs

  • Files

  • Tables

  • Queues


πŸ› οΈ Create a Storage Account

bashCopyEditaz storage account create \
  --name mystorageaccount123 \
  --resource-group myResourceGroup \
  --location eastus \
  --sku Standard_LRS
Parameter
Purpose

--name

Globally unique name

--resource-group

Where the Storage Account will be created

--location

Azure region

--sku

Storage redundancy options (LRS, GRS)

βœ… Name must be globally unique (only lowercase letters and numbers).


List Storage Accounts

bashCopyEditaz storage account list --output table

Delete a Storage Account

bashCopyEditaz storage account delete --name mystorageaccount123 --resource-group myResourceGroup

🌐 5.5 Creating Basic Networking Components


πŸ› οΈ Create a Virtual Network (VNet)

bashCopyEditaz network vnet create \
  --resource-group myResourceGroup \
  --name myVNet \
  --address-prefix 10.0.0.0/16 \
  --subnet-name mySubnet \
  --subnet-prefix 10.0.1.0/24

βœ… This creates a VNet and a Subnet at the same time.


πŸ›‘οΈ Create a Network Security Group (NSG)

bashCopyEditaz network nsg create \
  --resource-group myResourceGroup \
  --name myNSG

NSG controls inbound/outbound traffic to resources like VMs.


πŸ›‘οΈ Create an NSG Rule to Allow SSH (Linux VM)

bashCopyEditaz network nsg rule create \
  --resource-group myResourceGroup \
  --nsg-name myNSG \
  --name allow-ssh \
  --protocol Tcp \
  --direction Inbound \
  --priority 1000 \
  --source-address-prefixes '*' \
  --source-port-ranges '*' \
  --destination-address-prefixes '*' \
  --destination-port-ranges 22 \
  --access Allow

βœ… This opens port 22 (SSH) inbound.


🧹 5.6 Cleaning Up Resources

When you're done, delete the Resource Group to clean up everything inside it:

bashCopyEditaz group delete --name myResourceGroup

βœ… This deletes the VMs, Storage Accounts, VNets, everything inside the group.


πŸ“ Module 5 Summary

Topic
Key Points

Create VMs

az vm create

Connect to VMs

SSH (Linux) or RDP (Windows)

Manage VMs

Start, stop, restart, delete

Create Storage Accounts

az storage account create

Create Networking Components

VNet, Subnet, NSG

Clean up Resources

az group delete

Last updated 2 months ago