1) Remove the tailgate trim. Undo one screw
And then pull off the trim. Start with the sections by the window - these should come free quite easily with a little pull
There are a total of 8 fixing points, and some need quite a hard yank to free them. I tended to bend the trim at the top so that I could reach inside and apply pressure close to each point.
2) Check the wiring. In this pic you can see the white connector next to the green sticker. Maybe it just came off. If not, detach it and short the two connections which should turn the light on (if not then your problem lies elsewhere and is not covered by this post).
3) Remove the latch. You need to remove the two rods by simply unclipping the two plastic lugs and then pulling the rods away. Now undo to 2 13mm nuts and the latch comes free.
Here's the latch on the bench.
4) Check operation. Peer inside the latch (you might need a torch). You should see the red microswitch.
It should be fully out as shown.
Operate the latch by pushing it in with a screwdriver. Now a plastic lever should push in the switch as shown here.
5) Diagnose solution. My red switch must have been jammed, because during step 4 above, it seemed to start working again. However it doesn't seem to be fully fixed because sometimes the light won't come on and other times it will. Since the switch it not accessible (and is NOT itself a spare part in the Audi system), I have no choice but to replace the latch - I have contacted VAG parts...
6) Refit. Put everything back in place in reverse order, and just be careful when aligning the final parts of the trim (as shown in the photo above).