Had a rattle in my sunroof a while back. If it's the same problem I had, Audi said it was a 'common' and 'known' fault that they dealt with if/when it arose. My rattle was towards the rear of the sunroof, along the edge. Sometimes it was more of an annoying 'flutter' than a rattle. It was intermittent and nothing in particular seemed to set it off.
Left my car with them for a couple of days while they took out the lining and replaced some inadequate plastic brackets with more substantial purpose built metal parts.
No problems since.
Cheers, Paul.