Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1891

Top Azure CLI Commands For Managing Azure Resources

$
0
0

This blog details some of the top Azure CLI commands to create and manage Azure resources. When we start to consider automating the deployment and management of resources in Azure, the first option would be using the command line, and here we then have two further options: PowerShell and the Azure CLI.

PowerShell and the CLI are very similar: they both run from a command prompt, they both allow access to the Azure platform, and the commands are also very similar.

What Is Azure CLI And How Does It Work?

The Azure CLI is a standalone set of commands, which means that you do not need PowerShell. The Azure CLI is available for Windows, macOS, and Linux environments.

When using PowerShell or the Azure CLI through Cloud Shell, you are already authenticated; however, when using the tools from your own computer, you must first authenticate. Remember that the Azure REST APIs required a client access token, and because command-line tools essentially wrap calls to those APIs, you must log in to obtain the token.

Top Common Azure CLI Commands List

1) Manage resource groups and template deployments:

COMMANDS
az group create Create a new resource group.
az group delete Delete a resource group.
az group deployment Manage Azure Resource Manager deployments.
az group deployment cancel Cancels a currently running template deployment.
az group deployment create Start a deployment.
az group deployment delete Deletes a deployment from the deployment history.
az group deployment export Export the template used for deployment.
az group deployment list Get all the deployments for a resource group.
az group deployment operation Manage deployment operations.
az group deployment operation list Gets all deployments operations for deployment.
az group deployment operation show Get a deployment’s operation.
az group deployment show Gets a deployment.
az group exists Check if a resource group exists.
az group list List resource groups.
az group lock Manage Azure resource group locks.
az group lock create Create a resource group lock.
az group lock delete Delete a resource group lock.
az group show Gets a resource group.
az group update Update a resource group.

2) Manage Linux or Windows virtual machines.

COMMANDS
az vm application Manage applications for VM.
az vm application list List applications for VM.
az vm application set Set appliations for VM.
az vm assess-patches Assess patches on a VM.
az vm auto-shutdown Manage auto-shutdown for VM.
az vm availability-set Group resources into availability sets.
az vm availability-set create Create an Azure Availability Set.
az vm availability-set delete Delete an availability set.
az vm availability-set list List availability sets.
az vm availability-set list-sizes List VM sizes for an availability set.
az vm availability-set show Get information for an availability set.
az vm availability-set update Update an Azure Availability Set.
az vm capture Capture information for a stopped VM.
az vm convert Convert a VM with unmanaged disks to use managed disks.
az vm create Create an Azure Virtual Machine.
az vm deallocate Deallocate a VM.
az vm delete Delete a VM.
az vm diagnostics Configure the Azure Virtual Machine diagnostics extension.
az vm disk Manage the managed data disks attached to a VM.
az vm disk attach Attach a managed persistent disk to a VM. Please note that –ids only supports one disk.
az vm disk detach Detach a managed disk from a VM.
az vm encryption Manage encryption of VM disks.
az vm encryption show Show encryption status.
az vm extension Manage extensions on VMs.
az vm extension image list-versions List the versions for available extensions.
az vm get-instance-view Get instance information about a VM.
az vm host Manage Dedicated Hosts for Virtual Machines.
az vm host create Create a dedicated host.
az vm host delete Delete a dedicated host.
az vm identity Manage service identities of a VM.
az vm identity assign Enable managed service identity on a VM.
az vm identity remove Remove managed service identities from a VM.
az vm identity show Display VM’s managed identity info.
az vm image list-skus List the VM image SKUs available in the Azure Marketplace.
az vm list List details of Virtual Machines.
az vm list-ip-addresses List IP addresses associated with a VM.
az vm list-sizes List available sizes for VMs.
az vm list-skus Get details for compute-related resource SKUs.
az vm list-usage List available usage resources for VMs.
az vm list-vm-resize-options List available resizing options for VMs.
az vm monitor Manage monitor aspect for a vm.
az vm nic Manage network interfaces. See also az network nic.
az vm nic add Add existing NICs to a VM.
az vm nic list List the NICs available on a VM.
az vm open-port Opens a VM to inbound traffic on specified ports.
az vm redeploy Redeploy an existing VM.
az vm repair Auto repair commands to fix VMs.
az vm resize Update a VM’s size.
az vm restart Restart VMs.
az vm secret Manage VM secrets.
az vm secret add Add a secret to a VM.
az vm secret format Transform secrets into a form that can be used by VMs and VMSSes.
az vm secret list List secrets on a VM.
az vm secret remove Remove a secret from a VM.
az vm start Start a stopped VM.
az vm stop Power off (stop) a running VM.
az vm update Update the properties of a VM.
az vm user Manage user accounts for a VM.
az vm user delete Delete a user account from a VM.
az vm user reset-ssh Reset the SSH configuration on a VM.
az vm user update Update a user account.
az vm wait Place the CLI in a waiting state until a condition of the VM is met.

3) Manage storage accounts.

COMMANDS
az storage account check-name Check that the storage account name is valid and is not already in use.
az storage account create Create a storage account.
az storage account delete Delete a storage account.
az storage account encryption-scope Manage encryption scope for a storage account.
az storage account failover Failover request can be triggered for a storage account in case of availability issues.
az storage account file-service-properties Manage the properties of file service in storage account.
az storage account generate-sas Generate a shared access signature for the storage account.
az storage account keys Manage storage account keys.
az storage account list List storage accounts.
az storage account management-policy Manage storage account management policies.
az storage account network-rule Manage network rules.
az storage account or-policy Manage storage account Object Replication Policy.
az storage account or-policy create Create Object Replication Service Policy for storage account.
az storage account or-policy delete Delete specified Object Replication Service Policy associated with the specified storage account.
az storage account private-endpoint-connection Manage storage account private endpoint connection.
az storage account private-link-resource Manage storage account private link resources.
az storage account private-link-resource list Get the private link resources that need to be created for a storage account.
az storage account revoke-delegation-keys Revoke all user delegation keys for a storage account.
az storage account show Show storage account properties.
az storage account show-connection-string Get the connection string for a storage account.

4) Manage KeyVault keys, secrets, and certificates.

COMMANDS
az keyvault backup Manage full HSM backup.
az keyvault certificate Manage certificates.
az keyvault certificate create Create a Key Vault certificate.
az keyvault create Create a Vault or HSM.
az keyvault delete Delete a Vault or HSM.
az keyvault delete-policy Delete security policy settings for a Key Vault.
az keyvault key Manage keys.
az keyvault key backup Request that a backup of the specified key be downloaded to the client.
az keyvault key create Create a new key, stores it, then returns key parameters and attributes to the client.
az keyvault key decrypt Decrypt a single block of encrypted data.
az keyvault key delete Delete a key of any type from storage in Vault or HSM.
az keyvault key download Download the public part of a stored key.
az keyvault key encrypt Encrypt an arbitrary sequence of bytes using an encryption key that is stored in a Vault or HSM.
az keyvault key restore Restore a backed up key to a Vault or HSM.
az keyvault key rotate Rotate the key based on the key policy by generating a new version of the key.
az keyvault key rotation-policy Manage key’s rotation policy.
az keyvault key show Get a key’s attributes and, if it’s an asymmetric key, its public material.
az keyvault key show-deleted Get the public part of a deleted key.
az keyvault list List Vaults and/or HSMs.
az keyvault list-deleted Get information about the deleted Vaults or HSMs in a subscription.
az keyvault network-rule Manage vault network ACLs.
az keyvault recover Recover a Vault or HSM.
az keyvault restore Manage full HSM restore.
az keyvault restore start Restore a full backup of a HSM.
az keyvault role Manage user roles for access control.
az keyvault secret Manage secrets.
az keyvault secret backup Backs up the specified secret.
az keyvault secret list List secrets in a specified key vault.
az keyvault secret show Get a specified secret from a given key vault.
az keyvault storage Manage storage accounts.
az keyvault update Update the properties of a Vault.

5) Manage SQL servers.

COMMANDS
az sql server create Create a server.
az sql server delete Deletes a server.
az sql server dns-alias Manage a server’s DNS aliases.
az sql server firewall-rule Manage a server’s firewall rules.
az sql server firewall-rule create Create a firewall rule.
az sql server key Manage a server’s keys.
az sql server key create Creates a server key.
az sql server key show Shows a server key.
az sql server list List available servers.
az sql server list-usages Returns server usages.
az sql server outbound-firewall-rule Manage a server’s outbound firewall rules.
az sql server show Gets a server.
az sql server vnet-rule Manage a server’s virtual network rules.
az sql server vnet-rule create Create a virtual network rule to allows access to an Azure SQL server.
az sql server vnet-rule delete Deletes the virtual network rule with the given name.
az sql server vnet-rule list Gets a list of virtual network rules in a server.

Information Note  

A full list of Azure CLI commands can be found here: az | Microsoft Docs

Conclusion

Through PowerShell or the Azure CLI, you can perform any task, from obtaining information to creating, managing, and deleting resources.

One of the great benefits of either option is that you can perform actions on multiple resources by building logic-based routines. For example, if you wanted to build 100 VMs, you could write a script that would loop 100 times, automatically creating each VM.

The main drawback to scripting is that scripts can become quite complex, especially when deploying resources built from many different components; for example, VMs are actually built with additional components such as disks and network interface cards.

References/Related

Next Task For You

Begin your journey towards becoming a Microsoft Azure Solutions Architect ExpertJust click on the register now button below to register for a Free Class on Microsoft Azure Solutions Architect Expert Certification [AZ-305], which will help you to understand better, so you can choose the right path and clear the certification exam.

The post Top Azure CLI Commands For Managing Azure Resources appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1891

Trending Articles