AZ‐500 Microsoft Azure Security Technologies Study Guide_31 - itnett/FTD02H-N GitHub Wiki
Here's a set of important Azure CLI commands that are essential to know, particularly for the AZ-500 certification. Each command is accompanied by an explanation of what it does and how it fits into managing Azure resources. These commands will help you manage security, users, groups, resources, and much more.
az login
This command logs you into your Azure account via the CLI. If you haven't authenticated, it will open a browser window to complete the login process. It’s the first step before managing any Azure resources.
az ad user create --display-name "John Doe" --password "P@ssw0rd123!" --user-principal-name [email protected]
Creates a new Azure Active Directory user with the specified name, password, and user principal name (UPN).
az ad user list --output table
This command lists all Azure AD users in table format, making it easier to view the users in your organization.
az ad user delete --id [email protected]
Deletes an Azure AD user by specifying their user principal name or object ID.
az ad group create --display-name "Admins" --mail-nickname "Admins"
Creates a new security group in Azure Active Directory.
az ad group member add --group "Admins" --member-id <userObjectID>
Adds a user (specified by their object ID) to the specified group.
az ad group member list --group "Admins" --output table
Displays all the members of a group in table format for easy viewing.
az role assignment create --assignee <userPrincipalName> --role "Contributor" --scope /subscriptions/<subscriptionID>/resourceGroups/<resourceGroupName>
Assigns a role (e.g., Contributor) to a user or group for a specific resource group or subscription. This command is critical for managing access control to Azure resources.
az role assignment list --output table
Lists all role assignments across your Azure subscription, showing which users and groups have access to specific resources.
az group create --name MyResourceGroup --location "East US"
Creates a new resource group in the specified location. Resource groups are logical containers for managing multiple Azure resources.
az group delete --name MyResourceGroup --yes --no-wait
Deletes the specified resource group and all its resources. The --no-wait
flag ensures the command returns immediately, while the deletion happens asynchronously.
az vm create --resource-group MyResourceGroup --name MyVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
Creates a new virtual machine in Azure using the specified resource group and image (in this case, Ubuntu LTS). The SSH keys will be auto-generated for secure access.
az vm start --name MyVM --resource-group MyResourceGroup
Starts a stopped virtual machine, bringing it back online.
az vm stop --name MyVM --resource-group MyResourceGroup
Stops a running virtual machine, but it remains allocated (you’ll still be billed for storage).
az vm delete --resource-group MyResourceGroup --name MyVM --yes
Deletes the specified virtual machine and associated resources like disks and network interfaces.
az network nsg create --resource-group MyResourceGroup --name MyNSG
Creates a new Network Security Group (NSG) to manage inbound and outbound traffic for Azure resources like VMs.
az network nsg rule create --resource-group MyResourceGroup --nsg-name MyNSG --name MyNSGRule --priority 100 --protocol Tcp --destination-port-ranges 22 --access Allow
Adds a rule to allow SSH traffic (port 22) through the NSG. The priority defines the order of rules, with lower numbers taking precedence.
az network nsg rule list --resource-group MyResourceGroup --nsg-name MyNSG --output table
Displays all the rules for a specified NSG in a table format.
az keyvault create --name MyKeyVault --resource-group MyResourceGroup --location "East US"
Creates a new Azure Key Vault for storing secrets, certificates, and encryption keys securely.
az keyvault secret set --vault-name MyKeyVault --name "MySecret" --value "P@ssw0rd!"
Stores a new secret in the Key Vault, which can be retrieved securely by applications or services.
az keyvault secret show --name "MySecret" --vault-name MyKeyVault
Retrieves the value of a stored secret from the Key Vault.
az storage account create --name mystorageaccount --resource-group MyResourceGroup --location "East US" --sku Standard_LRS
Creates a new Azure storage account with locally redundant storage (LRS) in the specified region.
az storage account generate-sas --account-name mystorageaccount --permissions rwdlac --expiry 2023-12-31T00:00:00Z --services b --resource-types sco
Generates a shared access signature (SAS) token for the storage account, allowing controlled access to blobs with read, write, delete, list, add, and create permissions.
az storage container list --account-name mystorageaccount --output table
Lists all storage containers within the specified storage account in a table format.
az monitor activity-log alert create --name "HighCPUAlert" --resource-group MyResourceGroup --scope /subscriptions/<subscription-id> --condition "category=Administrative" --description "Alert on high CPU usage"
Creates an activity log alert based on a condition, such as administrative actions or high CPU usage. This is useful for monitoring Azure resources and setting up automatic responses.
Mastering these Azure CLI commands will significantly improve your ability to manage Azure resources, users, and security configurations. These commands form the backbone of automation and efficient resource management, which is critical for Azure security and operations.
For the AZ-500 exam, it’s important to not only know these commands but also understand the scenarios where they apply, such as setting up RBAC, managing users, securing resources, and monitoring activities.
Here is the continuation for the Next Page of Azure CLI commands relevant to AZ-500 in GitHub Wiki markdown format:
This page continues with more advanced and security-focused Azure CLI commands. These commands cover various aspects like configuring identity protection, managing security policies, configuring virtual networks, and more.
az ad conditionalaccess policy create --display-name "Require MFA for Admins" \
--conditions "{'users':{'includeUsers':['all'],'includeGroups':['AdminGroup']}}" \
--grant-controls "{'builtInControls':['mfa']}"
This command creates a Conditional Access Policy that enforces Multi-Factor Authentication (MFA) for all members of the specified group (e.g., AdminGroup). Conditional Access is crucial for securing Azure environments.
az ad conditionalaccess policy list --output table
Lists all Conditional Access policies in your Azure Active Directory tenant, showing key details like policy names, user conditions, and access controls.
az policy assignment create --name "EnforceTagging" --policy "/providers/Microsoft.Authorization/policyDefinitions/Tagging" \
--scope "/subscriptions/<subscription-id>"
This command assigns an existing Azure policy that enforces resource tagging across the specified subscription. Azure Policy ensures compliance with organizational standards by auditing or denying non-compliant resources.
az policy definition list --output table
Displays all policy definitions available in Azure, including built-in and custom policies that help manage and enforce security and compliance across your resources.
az 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
Creates a new virtual network (VNet) with a specified address space and a subnet. VNets are crucial for networking Azure resources like virtual machines and databases.
az network vnet peering create --name Vnet1ToVnet2 --resource-group MyResourceGroup --vnet-name Vnet1 --remote-vnet /subscriptions/<sub-id>/resourceGroups/OtherResourceGroup/providers/Microsoft.Network/virtualNetworks/Vnet2 --allow-vnet-access
Creates peering between two virtual networks (VNet1 and VNet2), allowing them to communicate with each other securely. This is commonly used to connect resources across different VNets.
az network vnet list --output table
Lists all virtual networks within the specified resource group or subscription in a table format for easy viewing.
az network firewall create --name MyFirewall --resource-group MyResourceGroup --location "East US"
Creates an Azure Firewall, a managed cloud-based network security service that protects Azure Virtual Network resources.
az network firewall rule create --firewall-name MyFirewall --resource-group MyResourceGroup --collection-name "AllowSSH" --rule-name "AllowSSH" --priority 100 \
--rule-type NetworkRule --action Allow --protocols "TCP" --source-addresses "*" --destination-addresses "10.0.1.0/24" --destination-ports 22
Creates a network rule in the Azure Firewall to allow SSH traffic (port 22) to a specific subnet (10.0.1.0/24). Network rules in Azure Firewall are used to control inbound and outbound traffic.
az network firewall rule list --firewall-name MyFirewall --resource-group MyResourceGroup --output table
Lists all firewall rules configured for the specified Azure Firewall.
az sentinel workspace create --resource-group MyResourceGroup --name MySentinelWorkspace --location "East US"
Creates an Azure Sentinel workspace for security event monitoring. Sentinel integrates with various data sources to provide a centralized view of security operations.
az sentinel data-connector create --workspace-name MySentinelWorkspace --resource-group MyResourceGroup --kind AzureActiveDirectory --name "AADConnector"
Adds a data connector (such as Azure Active Directory) to Azure Sentinel, allowing it to collect security-related logs and events for monitoring.
az sentinel alert-rule create --resource-group MyResourceGroup --workspace-name MySentinelWorkspace --name "HighCPUAlert" --query "SearchQuery" --severity "High" --enabled true
Creates a custom alert rule in Azure Sentinel that triggers when specific conditions (e.g., high CPU usage) are met. This allows automated monitoring and alerting.
az security pricing create --name default --tier Standard
Enables the Standard tier of Azure Security Center, which provides advanced threat detection, vulnerability assessments, and just-in-time VM access.
az security assessment list --output table
Lists all security recommendations provided by Azure Security Center, such as enabling multi-factor authentication (MFA) or updating outdated configurations.
az security jit-policy create --resource-group MyResourceGroup --name MyVM --ports '[{"number":22,"protocol":"*","allowedSourceAddressPrefix":"*","maxRequestAccessDuration":"PT3H"}]'
Configures Just-in-Time access for an Azure VM. In this example, it allows SSH (port 22) access for a maximum of 3 hours.
az backup protection enable-for-vm --resource-group MyResourceGroup --vault-name MyRecoveryVault --vm MyVM
Enables Azure Backup for a specified virtual machine, automatically backing up its state for future recovery.
az backup protection backup-now --resource-group MyResourceGroup --vault-name MyRecoveryVault --container-name MyVM --item-name MyVMItem --retain-until 2023-12-31
Manually triggers a backup job for the specified VM, with the backup retention set until the specified date.
az backup restore restore-disks --resource-group MyResourceGroup --vault-name MyRecoveryVault --container-name MyVM --item-name MyVMItem --restore-to-staging-storage-account MyStorageAccount
Restores a VM from an existing backup, placing the restored VM disks into a specified storage account for recovery.
az network vnet update --name MyVNet --resource-group MyResourceGroup --ddos-protection true --ddos-protection-plan /subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Network/ddosProtectionPlans/<plan-name>
Enables DDoS Protection for a virtual network, safeguarding it against Distributed Denial of Service attacks.
az network ddos-protection list --output table
Lists all DDoS Protection plans configured in the Azure environment.
This extended set of Azure CLI commands is critical for managing security, resources, and identity in Azure environments. As you study for the AZ-500 certification, mastering these commands will help you manage your infrastructure efficiently and securely.
Feel free to continue practicing with these commands in a lab environment to gain the practical experience needed for the exam!
This next page expands your Azure CLI toolkit with more advanced, security-focused commands, ideal for mastering the skills needed for the AZ-500 exam.