Microbial community composition, function, and viability are important for biofilm-based sewage treatment technologies. Most studies of microbial communities mainly rely on the total deoxyribonucleic acid (DNA) extracted from the biofilm. However, nucleotide materials released from dead microorganisms may interfere with the analysis of viable microorganisms and their metabolic potential. In this study, we developed a protocol to assess viability as well as viable community composition and function in biofilm in a sewage treatment system using propidium monoazide (PMA) coupled with real-time quantitative polymerase chain reaction (qPCR) and metagenomic technology. The optimal removal of PMA from non-viable cells was achieved by a PMA concentration of 4 μM, incubation in darkness for 5 min, and exposure for 5 min. Simultaneously, the detection limit can reach a viable bacteria proportion of 1%, within the detection concentration range of 102-108 CFU/mL (colony forming unit/mL), showing its effectiveness in removing interference from dead cells. Under the optimal conditions, the result of PMA-metagenomic sequencing revealed that 6.72% to 8.18% of non-viable microorganisms were influenced and the composition and relative abundance of the dominant genera were changed. Overall, this study established a fast, sensitive, and highly specific biofilm viability detection method, which could provide technical support for accurately deciphering the structural composition and function of viable microbial communities in sewage treatment biofilms.