A search for dark matter in association with a Higgs boson decaying to two photons is presented. This study is based on data collected with the ATLAS detector, corresponding to an integrated luminosity of 36.1??fb-1 of proton-proton collisions at the LHC at a center-of-mass energy of 13?TeV in 2015 and 2016. No significant excess over the expected background is observed. Upper limits at 95%?confidence level are set on the visible cross section for beyond the Standard Model physics processes, and the production cross section times branching fraction of the Standard Model Higgs boson decaying into two photons in association with missing transverse momentum in three different benchmark models. Limits at 95%?confidence level are also set on the observed signal in two-dimensional mass planes. Additionally, the results are interpreted in terms of 90%?confidence-level limits on the dark-matter?nucleon scattering cross section, as a function of the dark-matter particle mass, for a spin-independent