  Diazonium reactions with carbon nanotubes form optical $sp^3$ defects that
can be used in optical and electrical circuits. We investigate a direct
on-device reaction supported by confined laser irradiation and present a
technique where an arbitrary carbon nanotube can be preferentially
functionalized within a device by matching the light frequency with its
transition energy. An exemplary reaction was carried out between (9,7) nanotube
and 4-bromobenzenediazonium tetrafluoroborate. The substrate supported
nanotubes of multiple semiconducting chiralities were locally exposed to laser
light while monitoring the reaction kinetics in-situ via Raman spectroscopy.
The chiral selectivity of the reaction was confirmed by resonant Raman
spectroscopy, reporting a 10 meV $E_{22}$ transition energy red-shift only of
the targeted species. We further demonstrated this method on a single tube
(9,7) electroluminescent device and show a 25 meV red-shifted emission of the
ground state $E_{11}$ compared to the emission from the pristine tubes.
