Diazo compounds can be obtained in an elimination reaction of N-alkyl-N-nitroso compounds, such as in the synthesis of diazomethane from Diazald or MNNG:
(The mechanism shown here is one possibility.  For an alternative mechanism for the analogous formation of diazomethane from an N-nitrososulfonamide, see the page on Diazald.)