oven-sh/bun · error · Error
[azure] Command failed (exit ${result.exitCode}): ${command.
Error message
[azure] Command failed (exit ${result.exitCode}): ${command.join(" ")}\n${msg} What it means
Thrown by spawnSafeFn in the Azure provider when an Azure Run Command invocation is judged failed. Failure is detected solely from displayStatus === "Provisioning failed" because stderr routinely carries harmless output (rustup progress, cargo warnings, PowerShell Write-Warning). The message embeds the joined command plus the output tail — Run Command only returns the last 4096 bytes.
Source
Thrown at scripts/azure.mjs:545
const values = result?.value ?? [];
const stdout = values[0]?.message ?? "";
const stderr = values[1]?.message ?? "";
if (opts?.stdio === "inherit") {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
}
// Only use displayStatus to detect errors — stderr often contains non-error
// output (rustup progress, cargo warnings, PowerShell Write-Warning, etc.)
const hasError = values.some(v => v?.displayStatus === "Provisioning failed");
const exitCode = hasError ? 1 : 0;
return { exitCode, stdout, stderr };
};
const spawnSafeFn = async (command, opts) => {
const result = await spawnFn(command, opts);
if (result.exitCode !== 0) {
const msg = result.stderr || result.stdout || "Unknown error";
throw new Error(`[azure] Command failed (exit ${result.exitCode}): ${command.join(" ")}\n${msg}`);
}
return result;
};
const upload = async (source, destination) => {
// Read the file locally and write it on the VM via Run Command
const { readFileSync } = await import("node:fs");
const content = readFileSync(source, "utf-8");
// Escape for PowerShell — use base64 to avoid escaping issues
const b64 = Buffer.from(content).toString("base64");
const script = [
`$bytes = [Convert]::FromBase64String('${b64}')`,
`$dir = Split-Path '${destination}' -Parent`,
`if (-not (Test-Path $dir)) { New-Item -Path $dir -ItemType Directory -Force | Out-Null }`,
`[IO.File]::WriteAllBytes('${destination}', $bytes)`,
`Write-Host "Uploaded to ${destination} ($($bytes.Length) bytes)"`,
];
console.log(`[azure] Uploading ${source} -> ${destination}`);
await runCommand(vmName, script);View on GitHub (pinned to 8c5296ac45)
Solutions
- Read the command and output tail embedded in the message to identify the failing step
- Reproduce on the VM manually via az vm run-command invoke on the same machine
- Fix the underlying build/script failure — this error only surfaces it
- If the 4096-byte tail truncates the useful part, tee full output to a file on the VM and fetch it with a follow-up Run Command
Defensive patterns
Strategy: try-catch
Try / catch
try {
await spawnSafe(["cargo", "build"], {});
} catch (e) {
if (String(e.message).startsWith("[azure] Command failed")) {
// message body already carries the command and the last 4096 bytes of output;
// persist the full log before the VM is torn down
await upload("build.log", "C:/logs/build.log");
}
throw e;
} Prevention
- Tee remote command output to a file on the VM, not just stdout
- Remember stderr content is ignored for error detection — only displayStatus decides
- Keep remote steps small so a 4096-byte tail is enough to diagnose
When it happens
Trigger: Any remote step (rustup install, cargo build, PowerShell provisioning script) exits non-zero on the Windows VM, which Azure records as Provisioning failed for the Run Command extension.
Common situations: Rust toolchain install failing on a fresh VM; cargo build errors from source regressions or OOM on the Standard_D4ds_v6/D4pds_v6 size; PowerShell scripts terminating mid-run; disk full on the temp VM.
Related errors
- Azure secret not found: ${name}
- [azure] Unsupported OS: ${os}
- [azure] Failed to get public IP for ${vmName}
- [azure] Image replication failed: ${JSON.stringify(ver?.prop
- Azure auth failed: ${response.status}
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/93470ccaf48308d0.
Report an issue: GitHub.