This commit is contained in:
Toby
2026-01-27 17:35:45 -05:00
commit 2639af6531
176 changed files with 27104 additions and 0 deletions
@@ -0,0 +1,45 @@
---
name: azure-vms
description: Manage Azure Virtual Machines and scale sets. Configure availability sets and managed disks. Use when deploying compute resources on Azure.
license: MIT
metadata:
author: devops-skills
version: "1.0"
---
# Azure Virtual Machines
Deploy and manage Azure VMs and scale sets.
## Create VM
```bash
az vm create \
--resource-group mygroup \
--name myvm \
--image Ubuntu2204 \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--nsg-rule SSH
```
## Scale Sets
```bash
az vmss create \
--resource-group mygroup \
--name myvmss \
--image Ubuntu2204 \
--instance-count 2 \
--vm-sku Standard_B2s \
--upgrade-policy-mode automatic
```
## Best Practices
- Use managed disks
- Implement availability zones
- Use scale sets for auto-scaling
- Enable Azure Backup
- Use spot instances for cost savings
@@ -0,0 +1,99 @@
# Azure VM Operations Reference
## VM Management
```bash
# Create VM
az vm create \
--resource-group myRG \
--name myVM \
--image Ubuntu2204 \
--admin-username azureuser \
--generate-ssh-keys \
--size Standard_B2s
# Start/Stop/Delete
az vm start --resource-group myRG --name myVM
az vm stop --resource-group myRG --name myVM
az vm deallocate --resource-group myRG --name myVM
az vm delete --resource-group myRG --name myVM --yes
# List VMs
az vm list --resource-group myRG -o table
az vm list-ip-addresses --resource-group myRG -o table
```
## VM Sizes
| Size | vCPU | Memory | Use Case |
|------|------|--------|----------|
| Standard_B1s | 1 | 1 GB | Dev/Test |
| Standard_B2s | 2 | 4 GB | Light workloads |
| Standard_D2s_v3 | 2 | 8 GB | General |
| Standard_F2s_v2 | 2 | 4 GB | Compute |
| Standard_E2s_v3 | 2 | 16 GB | Memory |
```bash
# List available sizes
az vm list-sizes --location eastus -o table
# Resize VM
az vm resize --resource-group myRG --name myVM --size Standard_D4s_v3
```
## Images
```bash
# List images
az vm image list --output table
az vm image list --publisher Canonical --all --output table
# Create image from VM
az vm deallocate --resource-group myRG --name myVM
az vm generalize --resource-group myRG --name myVM
az image create --resource-group myRG --name myImage --source myVM
```
## Custom Script Extension
```bash
az vm extension set \
--resource-group myRG \
--vm-name myVM \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"commandToExecute":"apt-get update && apt-get install -y nginx"}'
```
## Terraform
```hcl
resource "azurerm_linux_virtual_machine" "main" {
name = "myVM"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
size = "Standard_B2s"
admin_username = "azureuser"
admin_ssh_key {
username = "azureuser"
public_key = file("~/.ssh/id_rsa.pub")
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
network_interface_ids = [
azurerm_network_interface.main.id,
]
}
```