Azobenzene, which activates its geometric and chemical structure under light stimulation enables noninvasive control of mass transport in many processes including membrane separations. However, producing azobenzene-decorated channels that have precise size tunability and favorable pore wall chemistry allowing fast and durable permeation to solvent molecules, remains a great challenge. Herein, an advanced membrane that comprises geometry and polarity gradients within covalent organic framework (COF) nanochannels utilizing photoisomerization of azobenzene groups is reported. Such functional variations afford reduced interfacial transfer resistance and enhanced solvent-philic pore channels, thus creating a fast solvent transport pathway without compromising selectivity. Moreover, the membrane sets up a densely covered defense layer to prevent foulant adhesion and the accumulation of cake layer, contributing to enhanced antifouling resistance to organic foulants, and a high recovery rate of solvent permeance. More importantly, the solvent permeance displays a negligible decline throughout the long-term filtration for over 40 days. This work reports the geometry and polarity gradients in COF channels induced by the conformation change of branched azobenzene groups and demonstrates the strong capability of this conformation change in realizing fast and durable molecular separations.