Finding the AES key with access to the function
No. What you have access to is called an oracle. It is an entity that encrypts or decrypts arbitrary data with a given secret key. A modern and secure block cipher like AES remains secure from key recovery even in the face of an encryption or decryption oracle. If it was not, the cipher would be considered fatally broken. The best-known way to recover the key with what you have is exhaustive search (brute force).