Ammonia formation was studied in a series of dedicated nitrogen seeded H-mode discharges at ASDEX Upgrade. The evolution of ammonia formation was investigated with a reference phase before the seeding, and a long, stable flat-top nitrogen-seeded phase. It was monitored with divertor spectroscopy and analysis of the exhaust gas. The amount of the detected ammonia increased continuously over the course of five discharges with the same nitrogen seeding rate. The same trend was observed in the nitrogen density in the core plasma, as measured by charge exchange recombination spectroscopy and other signals, linked to the effects of nitrogen seeding. The results show that the rate of ammonia formation exhibited the same trend as the nitrogen density in the plasma. This density, in turn, was strongly influenced by the nitrogen wall inventory. The spatial distribution of the detected ammonia suggests that a significant contribution to the net ammonia formation is made in plasma-shaded areas, through surface reactions of neutral species.