The random transverse-field Ising chain is the simplest disordered model presenting a quantum phase transition at $T=0.$ We compare analytically its finite-size scaling properties in two different ensembles for the disorder: (i) the canonical ensemble, where the disorder variables are independent and (ii) the microcanonical ensemble, where there exists a global constraint on the disorder variables. The observables under study are the surface magnetization, the correlation of the two surface magnetizations, the gap and the end-to-end spin-spin correlation $C(L)$ for a chain of length L. At criticality, each observable decays typically as ${e}^{\ensuremath{-}w\sqrt{L}}$ in both ensembles, but the probability distributions of the rescaled variable w are different in the two ensembles, in particular, in their asymptotic behaviors. As a consequence, the dependence on L of averaged observables differs in the two ensembles. For instance, the correlation $C(L)$ decays algebraically as $1/L$ in the canonical ensemble, but subexponentially as ${e}^{\ensuremath{-}{\mathrm{cL}}^{1/3}}$ in the microcanonical ensemble. Off criticality, probability distributions of rescaled variables are governed by the critical exponent $\ensuremath{\nu}=2$ in both ensembles, but the following observables are governed by the exponent $\stackrel{\ifmmode \tilde{}\else \~{}\fi{}}{\ensuremath{\nu}}=1$ in the microcanonical ensemble, instead of the exponent $\ensuremath{\nu}=2$ in the canonical ensemble: (a) In the disordered phase, the averaged surface magnetization, the averaged correlation of the two surface magnetizations and the averaged end-to-end spin-spin correlation; (b) in the ordered phase, the averaged gap. In conclusion, the measure of the rare events that dominate various averaged observables can be very sensitive to the microcanonical constraint.