Describe the bug
Description
az serial-console connect prints raw Python bytes repr strings (e.g. b'\r\r\n', b'login: ') instead of decoded text when running in WSL or any environment where websocket-client delivers binary WebSocket frames.
Steps to Reproduce
- Run
az serial-console connect --name <vm> --resource-group <rg> from WSL
- Observe garbled output like:
b'\r\r\n'b'myvmname login: 'b'\r\r\n'b'myvmname login: '
Root Cause
In custom.py, the on_message callback passes message directly to PC.print(). When websocket-client receives a binary WebSocket frame, it delivers a bytes object. PC.print() calls Python's print() on it, which renders as b'...' repr instead of actual text.
def on_message(_, message):
...
else:
PC.print(message) # message may be bytes, not str
Fix
Decode bytes to str before printing:
def on_message(_, message):
...
else:
if isinstance(message, bytes):
message = message.decode('utf-8', errors='replace')
PC.print(message)
Environment
- OS: WSL2 (Fedora)
az serial-console extension version: 1.0.0b3
websocket-client version: 1.3.1
Related command
az serial-console connect --name --resource-group
Errors
Output looks like:
Started \x1b[0;1;39mazsecmond.service\x1b[0m - Azure security monitoring daemon.\r\n[\x1b[0;1;31mFAILED\x1b[0m] Failed to start \x1b[0;1;39mazsecmond.service\x1b[0m - Azure security monitoring daemon.\r\nSee 'systemctl status azsecmond.service' for details.\r\n
Issue script & Debug output
n/a
Expected behavior
Properly formatted output like:
[ OK ] Stopped systemd-tmpfiles-setup-dev…ic Device Nodes in /dev gracefully.
[ OK ] Stopped kmod-static-nodes.service …Create List of Static Device Nodes.
[ OK ] Stopped systemd-vconsole-setup.service - Virtual Console Setup.
[ OK ] Finished initrd-udevadm-cleanup-db.service - Cleanup udev Database.
[ OK ] Reached target initrd-switch-root.target - Switch Root.
Environment Summary
$ az --version
azure-cli 2.84.0 *
core 2.84.0 *
telemetry 1.1.0
Extensions:
azure-devops 1.0.2
serial-console 1.0.0b3
Dependencies:
msal 1.35.0b1
azure-mgmt-resource 24.0.0
Python location '/usr/sbin/python3.12'
Config directory '/var/azure'
Extensions directory '/var/azure/cliextensions'
Python (Linux) 3.12.12 (main, Jan 16 2026, 00:00:00) [GCC 15.2.1 20251211 (Red Hat 15.2.1-5)]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 update(s) available. Consider updating your CLI installation with 'az upgrade'
Additional context
No response
Describe the bug
Description
az serial-console connectprints raw Pythonbytesrepr strings (e.g.b'\r\r\n',b'login: ') instead of decoded text when running in WSL or any environment wherewebsocket-clientdelivers binary WebSocket frames.Steps to Reproduce
az serial-console connect --name <vm> --resource-group <rg>from WSLRoot Cause
In
custom.py, theon_messagecallback passesmessagedirectly toPC.print(). Whenwebsocket-clientreceives a binary WebSocket frame, it delivers abytesobject.PC.print()calls Python'sprint()on it, which renders asb'...'repr instead of actual text.Fix
Decode
bytestostrbefore printing:Environment
az serial-consoleextension version: 1.0.0b3websocket-clientversion: 1.3.1Related command
az serial-console connect --name --resource-group
Errors
Output looks like:
Started \x1b[0;1;39mazsecmond.service\x1b[0m - Azure security monitoring daemon.\r\n[\x1b[0;1;31mFAILED\x1b[0m] Failed to start \x1b[0;1;39mazsecmond.service\x1b[0m - Azure security monitoring daemon.\r\nSee 'systemctl status azsecmond.service' for details.\r\n
Issue script & Debug output
n/a
Expected behavior
Properly formatted output like:
[ OK ] Stopped systemd-tmpfiles-setup-dev…ic Device Nodes in /dev gracefully.
[ OK ] Stopped kmod-static-nodes.service …Create List of Static Device Nodes.
[ OK ] Stopped systemd-vconsole-setup.service - Virtual Console Setup.
[ OK ] Finished initrd-udevadm-cleanup-db.service - Cleanup udev Database.
[ OK ] Reached target initrd-switch-root.target - Switch Root.
Environment Summary
$ az --version
azure-cli 2.84.0 *
core 2.84.0 *
telemetry 1.1.0
Extensions:
azure-devops 1.0.2
serial-console 1.0.0b3
Dependencies:
msal 1.35.0b1
azure-mgmt-resource 24.0.0
Python location '/usr/sbin/python3.12'
Config directory '/var/azure'
Extensions directory '/var/azure/cliextensions'
Python (Linux) 3.12.12 (main, Jan 16 2026, 00:00:00) [GCC 15.2.1 20251211 (Red Hat 15.2.1-5)]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 update(s) available. Consider updating your CLI installation with 'az upgrade'
Additional context
No response