Photon detectors are an elementary tool to measure electromagnetic waves at the quantum limit and are heavily demanded in the emerging quantum technologies such as communication, sensing, and computing. Of particular interest is a quantum non-demolition (QND) type detector, which projects the quantum state of a photonic mode onto the photon-number basis without affecting the temporal or spatial properties. This is in stark contrast to conventional photon detectors which absorb a photon to trigger a `click and thus inevitably destroy the photon. The long-sought QND detection of a flying photon was recently demonstrated in the optical domain using a single atom in a cavity. However, the counterpart for microwaves has been elusive despite the recent progress in microwave quantum optics using superconducting circuits. Here, we implement a deterministic entangling gate between a superconducting qubit and a propagating microwave pulse mode reflected by a cavity containing the qubit. Using the entanglement and the high-fidelity qubit readout, we demonstrate a QND detection of a single photon with the quantum efficiency of 0.84, the photon survival probability of 0.87, and the dark-count probability of 0.0147. Our scheme can be a building block for quantum networks connecting distant qubit modules as well as a microwave photon counting device for multiple-photon signals.