P0171 is system too lean. This means you have an air leak which can cause a misfire.
Check these hoses. They go under the intake manifold. Look for oil or splits or listen for a hissing sound. Check these before you do the coils.
Here is the link for the coils. http://www.bimmerspecialist.com/usa/parts/index/audi
You want Part# : 06B 905 115 R They are the latest and greatest coils.