Based on the urban natural gas pipeline accident statistics and semi-quantitative risk evaluation index system, this paper applies Bayesian network to establish a network model between various types of risk factors and the risk of natural gas pipeline failure. The EM algorithm was used to learn from the statistical accident data to obtain the parameters of the model. Based on the principle of evidential reasoning in reverse, the probability of occurrence of all risk indicators can be obtained when the probability of occurrence of urban natural gas pipeline accidents is 100%, the index weight is obtained by normalizing the occurrence probability. On this basis, this paper develops an efficient urban natural gas pipeline integrity risk identification and management software. The software can realize the basic data management of urban natural gas pipeline system, pipeline relative risk value calculation, pipeline risk level calculation and other functions, and the results are visualized. Finally, the practicability and effectiveness of the model and software are verified by a case of natural gas pipeline evaluation in a block.