Are you using the library https://pypi.org/project/azure-search-documents/?
This is the official Azure AI Search Python SDK but there is no as_retriever method.
(I am a Microsoft employee working in the Azure SDK team.)