# Overview
Azure Virtual Machines (VMs) are scalable computing resources offered by Microsoft Azure that allow developers to run applications in a virtualized environment. They provide the flexibility of virtualization without the need to buy and maintain the physical hardware that runs it.
# Key Features
Azure Virtual Machines in the context of an Azure Cloud Data Center offer various key features including:
- **Scalability:** Easily scale your applications by adjusting the number of VMs to match your workload demands.
- **Flexibility:** Choose from a wide range of VM sizes and configurations to suit different workloads, whether you're running a small test application or a large-scale mission-critical operation.
- **Managed Disks:** Offering simplicity of data management and increased reliability, managed disks endure the cumbersome aspect of resizing and configuring disks.
- **Interoperability:** Support for various operating systems, including Windows and several Linux distributions, ensuring compatibility for diverse applications.
- **Security:** Built-in capabilities like host-level and managed disk encryption and integration with Azure Security Center help protect your workloads against threats.
# Importance
Utilizing Azure Virtual Machines in an Azure Cloud Data Center is crucial for several reasons:
- **Cost Efficiency:** Pay only for what you use, offering potential cost savings compared to maintaining on-premises infrastructure.
- **High Availability:** Leverage features such as Availability Zones and Load Balancing to ensure your applications remain accessible.
- **Global Reach:** Deploy applications across the globe with data centers available in numerous regions, allowing you to adhere to data residency and compliance requirements.
- **Disaster Recovery:** Integrated with Azure's backup and disaster recovery services, providing a robust support system to maintain uptime and data integrity.
# Use Cases
Azure Virtual Machines find use in various scenarios in an Azure Data Center, such as:
- **Development and Testing:** Create isolated environments for developers to build and test applications without impacting production.
- **Web Hosting:** Host websites and web applications efficiently with the ability to handle traffic spikes by scaling up resources.
- **Enterprise Applications:** Run line-of-business applications like SAP, SQL Server, and Oracle databases on scalable and reliable virtual infrastructure.
- **Data Analysis and Processing:** Execute large-scale data processing jobs to gain insights from vast datasets using optimal VM configurations.
Azure Virtual Machines provide a versatile and efficient platform for running a wide range of applications and workloads in the cloud.
[[Azure Managed Disks]]
[[VM Management and Advanced Options]]
## Connecting to a VM
[[Azure Bastion]] is a managed service via Microsoft is the most secure way of connecting to a virtual machine. It does not require any open ports.
Both [[Remote Desktop Protocol]] (for connecting to Windows VMs) and [[SSH]] (for connecting to Linux VMs) require ports to be open and a [[Public IP]]
## Availability
When creating a VM in Azure, you have a few different options to enhance the availability and reliability of your VMs.
[[Availability Set]]
[[Availability Zone]]
[[Virtual Machine Scale Set]]
## Manage VMs through PowerShell
### Create a VM in PowerShell
[New-AzVM (Az.Compute) | Microsoft Learn](https://learn.microsoft.com/en-us/powershell/module/az.compute/new-azvm?view=azps-13.0.0)
```PowerShell
# Create VM
Connect-AzAccount
New-AZResourceGroup -Name myrg - Location CanadaCentral
New-AzVM -Name VM1 -ResourceGroup myrg -Location CanadaCentral
Invoke-AzVMRunCommand -ResourceGroupName 'myrg' -VMName 'VM1' -CommandId 'RunPowerShellScript' -ScriptString 'Install-WindowsFeature -Name Web-Server -IncludeManagementTools'
```
### Manage VM in PowerShell
```powershell
# Manage VM
Stop-AzVM -ResourceGroupName 'myrg' -Name 'VM1'
Start-AzVM -ResourceGroupName 'myrg' -Name 'VM1'
Restart-AzVM -ResourceGroupName 'myrg' -Name 'VM1'
# Delete VM
Remove-AzVM -ResourceGroupName 'myrg' -Name 'VM1'
Remove-AzResourceGroup -Name 'myrg'
```
## Resources
[Create a Windows virtual machine in Azure - Training | Microsoft Learn](https://learn.microsoft.com/en-us/training/modules/create-windows-virtual-machine-in-azure/)
### Interactive lab simulations
[Lab - Manage Virtual Machines](https://github.com/MicrosoftLearning/AZ-104-MicrosoftAzureAdministrator/blob/master/Instructions/Labs/LAB_08-Manage_Virtual_Machines.md#interactive-lab-simulations)
There are interactive lab simulations that you might find useful for this topic. The simulation lets you to click through a similar scenario at your own pace. There are differences between the interactive simulation and this lab, but many of the core concepts are the same. An Azure subscription is not required.
- [Create a virtual machine in the portal](https://mslearn.cloudguides.com/en-us/guides/AZ-900%20Exam%20Guide%20-%20Azure%20Fundamentals%20Exercise%201). Create a virtual machine, connect and install the web server role.
- [Deploy a virtual machine with a template](https://mslearn.cloudguides.com/en-us/guides/AZ-900%20Exam%20Guide%20-%20Azure%20Fundamentals%20Exercise%209). Explore the QuickStart gallery and locate a virtual machine template. Deploy the template and verify the deployment.
- [Create a virtual machine with PowerShell](https://mslearn.cloudguides.com/en-us/guides/AZ-900%20Exam%20Guide%20-%20Azure%20Fundamentals%20Exercise%2010). Use Azure PowerShell to deploy a virtual machine. Review Azure Advisor recommendations.
- [Create a virtual machine with the CLI](https://mslearn.cloudguides.com/en-us/guides/AZ-900%20Exam%20Guide%20-%20Azure%20Fundamentals%20Exercise%2011). Use the CLI to deploy a virtual machine. Review Azure Advisor recommendations.