This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a CLI tool for creating Azure VMs quickly with sensible defaults. It's published as @todesktop/az-vm on npm and supports both Windows and Linux VMs.
# Run the CLI locally
node create-az-vm.js --help
# Test with different OS presets
node create-az-vm.js --image=ubuntu
node create-az-vm.js --image=windows-10 --location=uksouth# Publish to npm (requires npm login)
npm publish --access public
# Create GitHub release
gh release create v<version> --title "v<version> - Release Title" --notes "Release notes"The entire tool is contained in a single file (create-az-vm.js) with these key components:
- IMAGE_PRESETS object: Maps friendly names (e.g., 'ubuntu', 'windows-11') to full Azure image URNs
- OS Detection: Automatically detects Windows vs Linux from image name to:
- Set appropriate VM name length (Windows: 15 char limit)
- Configure correct NSG rules (RDP for Windows, SSH for Linux)
- Display OS-specific connection instructions
- Password Generation: Uses crypto.randomInt() to generate 16-character passwords meeting Azure requirements
- Azure CLI Wrapper: All Azure operations use execSync() to call
azCLI commands
Windows computer names cannot exceed 15 characters. The code handles this by using shorter names for Windows VMs:
args.name = `win-${Date.now().toString().slice(-8)}`; // Max 15 charsPasswords are escaped for shell execution using double quotes and escaping special characters:
const escapedPassword = args.password.replace(/"/g, '\\"').replace(/\$/g, "\\$");The default location is northeurope (Ireland) - this was changed from uksouth in the user's version.
When testing VM creation, remember:
- Use
az group delete --name <resource-group> --yesto clean up all resources - Windows VMs may take 5-10 minutes to be fully ready for RDP
- Linux VMs are created without GUI by default - GUI setup instructions are in README
- Package name:
@todesktop/az-vm - CLI binary name:
az-vm - Supports both
npx @todesktop/az-vmand global installation - No dependencies - uses only Node.js built-in modules