Conversion of pregnenolone and progesterone to their 17-alpha-hydroxylated products and subsequently to dehydroepiandrosterone (DHEA) and androstenedione. Catalyzes both the 17-alpha-hydroxylation and the 17,20-lyase reaction. a C21-steroid + O2 + reduced [NADPH--hemoprotein reductase] = a 17alpha-hydroxy-C21-steroid + H(+) + H2O + oxidized [NADPH--hemoprotein reductase] 17alpha-hydroxyprogesterone + O2 + reduced [NADPH--hemoprotein reductase] = acetate + androst-4-ene-3,17-dione + 2 H(+) + H2O + oxidized [NADPH--hemoprotein reductase] 17alpha-hydroxypregnenolone + O2 + reduced [NADPH--hemoprotein reductase] = 3beta-hydroxyandrost-5-en-17-one + acetate + 2 H(+) + H2O + oxidized [NADPH--hemoprotein reductase] Regulated predominantly by intracellular cAMP levels. Lipid metabolism; steroid biosynthesis. Belongs to the cytochrome P450 family.