# VM Deployment Quickstart

## Prerequisites

- Azure CLI installed and configured
- Terraform >= 1.0
- SSH key pair
- Azure subscription

## Quick Deployment

### 1. Configure Variables

```bash
# Copy example file
cp terraform/terraform.tfvars.vm.example terraform/terraform.tfvars.vm

# Edit with your values
export SSH_PUBLIC_KEY=$(cat ~/.ssh/id_rsa.pub)
cat > terraform/terraform.tfvars.vm <<EOF
vm_deployment_enabled = true
vm_regions = ["eastus"]
validator_vm_count = 2
sentry_vm_count = 2
rpc_vm_count = 2
use_vmss = false
ssh_public_key = "$SSH_PUBLIC_KEY"
vm_size_validator = "Standard_D4s_v3"
vm_size_sentry = "Standard_D4s_v3"
vm_size_rpc = "Standard_D8s_v3"
EOF
```

### 2. Deploy Infrastructure

```bash
cd terraform
terraform init
terraform plan -var-file=terraform.tfvars.vm -var="vm_deployment_enabled=true"
terraform apply -var-file=terraform.tfvars.vm -var="vm_deployment_enabled=true"
```

### 3. Verify Deployment

```bash
# Get VM IPs
terraform output vm_rpc_public_ips

# Check VM status
az vm list --resource-group defi-oracle-mainnet-rg --show-details

# SSH into VM
ssh besuadmin@<vm-ip>

# Check Besu container
docker ps
docker logs besu-validator-0
```

### 4. Test RPC Endpoint

```bash
# Test RPC endpoint
curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
  http://<rpc-vm-ip>:8545
```

## Multi-Region Deployment

```bash
# Update terraform.tfvars.vm
vm_regions = ["eastus", "westus", "westeurope"]

# Apply
terraform apply -var-file=terraform.tfvars.vm
```

## VM Scale Sets

```bash
# Update terraform.tfvars.vm
use_vmss = true

# Apply
terraform apply -var-file=terraform.tfvars.vm
```

## Management

### Monitor VMs

```bash
./scripts/vm-deployment/monitor-vm.sh
```

### Update Configuration

```bash
./scripts/vm-deployment/update-vm-config.sh <vm-ip> validator config/validators/besu-config.toml
```

### Backup Data

```bash
./scripts/vm-deployment/backup-vm.sh <vm-ip>
```

### Restore Data

```bash
./scripts/vm-deployment/restore-vm.sh <vm-ip> <backup-file>
```

## Troubleshooting

See [VM Deployment Guide](VM_DEPLOYMENT.md) for detailed troubleshooting.

## Next Steps

- Configure monitoring
- Setup backups
- Configure alerts
- Deploy contracts
- Test network

