![]()
Azure AI Services via SDK & REST API, offered by Microsoft, provide a set of powerful tools for developers and data scientists to create smart applications. These tools cover areas like vision (image recognition), speech (voice recognition), decision-making, and understanding language.
However, as with any complex platform, developers can run into errors while using these services through the Azure SDKs (software development kits) or REST APIs (programming interfaces), such as ErrNo 11001 Get Addrinfo Failed No module named Azure dotenv.
In this blog, we’ll look at some common mistakes developers often make when starting with Azure AI services, including issues like ErrNo 11001 Get Addrinfo Failed and No module named Azure & dotenv error fix. We’ll offer easy-to-follow tips to help you fix these issues quickly and avoid the common traps beginners fall into.
Topics covered in this blog are:
Understanding Azure AI Services via SDK & REST API
Microsoft’s cloud platform offers a broad set of Azure AI services to build and deploy machine learning models, integrate cognitive services, and use pre-built AI solutions. You can access these services through two primary methods: the Azure SDKs or the REST APIs.
- Azure SDKs: Microsoft provides SDKs for various programming languages (e.g., Python, C#, Java) to interact with Azure services. The SDKs offer a more abstract, easier-to-use interface compared to raw HTTP requests via the REST API.
- REST APIs: The REST API offers direct access to Azure services through HTTP requests. While it provides more control over interactions with the service, it can be more challenging to use than the SDKs for some developers.

To know more about Azure Cognitive Services Types and Benefits visit our blog: Click here
Errors during interaction with these services can arise in both cases, whether it’s through misconfigured SDKs or faulty API requests. Let’s dive into common issues like ErrNo 11001 Get Addrinfo Failed and No module named Azure & dotenv errors, and explore how to resolve them.
Common Errors Encountered in Azure AI Services
ERROR 1: ErrNo 11001: Get Addrinfo Failed
What does this error mean?
The ‘ErrNo 11001: Get Addrinfo Failed‘ error typically occurs when a program fails to resolve the DNS (Domain Name System) address. This often happens when the application tries to make HTTP requests to Azure services but cannot find the correct IP address for the server.
Common Causes and Fixes:
1. Improperly Saved .env File (Major Cause)Reason:
If your .env file is not properly saved or formatted, your application might fail to load the correct environment variables, such as API keys or service endpoints. Missing or misconfigured values in the .env file can cause the application to fail at resolving addresses or connecting to Azure services, resulting in a DNS resolution error.
Fix:
- Double-check the file format: Ensure your
.envfile is saved as a plain text file and correctly formatted. It should not have a.txtextension or contain any extra characters like invisible Unicode characters. - Check for extra spaces and invalid characters: Ensure that there are no extra spaces after keys or values, and that each variable is properly defined. For example,
KEY=VALUEwithout any spaces around the equal sign. - Ensure completeness: Verify that all required variables, such as
AZURE_ENDPOINT,AZURE_API_KEY, or other service-specific parameters, are included and properly assigned.
2. Network Configuration IssuesReason:
If your network is misconfigured or your DNS server can’t resolve Azure’s endpoints, you’ll get this error. This might happen if your internet connection is unstable or your DNS settings are incorrect.
Fix:
- Check your internet connection: Make sure your connection is stable.
- Test DNS resolution: Run
nslookup <azure-service-endpoint>in the command line to check if the address can be resolved correctly.
3. Firewall or Proxy RestrictionsReason:
Firewalls or proxies in corporate networks can block connections to Azure, causing DNS errors.
Fix:
- Check firewall settings: Ensure your firewall allows traffic to Azure services.
- Configure proxy: If you’re using a proxy, set it up in your app or system. For Python, you can use:
export HTTP_PROXY="http://yourproxy:port" export HTTPS_PROXY="http://yourproxy:port"
4. Incorrect Service EndpointReason:
If the endpoint URL you’re using is wrong or outdated, your app can’t find Azure’s services.
Fix:
- Check the endpoint URL: Make sure you’re using the correct URL for the Azure service you’re accessing. Double-check Azure’s documentation for the latest URLs.
5. DNS Server IssuesReason:
If your DNS server is down or unreliable, it can’t resolve Azure’s endpoints.
Fix:
- Switch DNS servers: Try using Google’s DNS (8.8.8.8) or Cloudflare’s DNS (1.1.1.1).
- Test with another device: Try your app on a different device or network to see if the issue is network-specific.
ERROR 2: Module Not Found Error: ‘No module named Azure’
This error arises when the Python interpreter cannot find the azure module. This typically means that the Azure SDK has not been installed correctly, or you’re using the wrong environment.
Common Causes:
1. Azure SDK Not Installed
- The required Azure SDK package, such as
azure-identityorazure-cognitiveservices-vision-computervision, may not have been installed in your environment.
2. Multiple Python Environments
- If you’re using different Python environments (like
virtualenvorAnaconda), there may be misconfiguration or the Azure SDK may be installed in one environment but not the other.
3. Incorrect Import Statement
- If your import statement is incorrect or refers to a module that’s part of a different Azure SDK package, Python won’t be able to find the correct module.
Fixes:
1. Install the Azure SDK Package
Run the following command to install the Azure SDK package:
pip install azure-identity
If you’re using other Azure services, such as Cognitive Services, install the corresponding package:
pip install azure-cognitiveservices-vision-computervision
2. Check Your Python Script
Ensure your import statements are correct and match the Azure SDK you’re using. For example, for authentication using, the import should be:
from azure.identity import AzureKeyCredential
3. Verify Your Environment
Make sure you’re working in the correct Python environment where the packages are installed:
- If you’re using a virtual environment, activate it before running your script:
source venv/bin/activate # For Unix-based systems .\venv\Scripts\activate # For Windows
- To check which packages are installed, use:
pip list
4. Reinstall the SDK
- If the issue persists, try reinstalling the Azure SDK:
pip uninstall azure-identity pip install azure-identity
Other Possible Causes:
1. Outdated or Broken Python Path
- Sometimes, the Python path may be pointing to a different or outdated version of Python that doesn’t have the necessary Azure SDK installed.
- Fix: Ensure that your
PYTHONPATHis pointing to the correct Python environment and version.
2. Dependency Conflicts
- If there are conflicting packages or versions of the Azure SDK, it might prevent Python from loading the module correctly.
- Fix: Use a clean virtual environment and install only the required dependencies to avoid conflicts.
ERROR 3: Module Not Found Error: ‘No module named dotenv’
What is this error indicating?
This error occurs when the Python script you’re running tries to import the dotenv module but it is not found in your environment. The dotenv module is typically used to load environment variables from a .env file, which is essential for securely managing credentials and configuration settings.
Common Causes:
1. python-dotenv Package Not Installed
The dotenv package, which is required to load environment variables from a .env file, is not installed in your environment.
2. Misconfigured .env File
If the .env file is missing, or the environment variables in it are not correctly defined, the script might fail to load the necessary values.
Fixes:
1. Install the python-dotenv Module
The error message indicates that the dotenv module is not installed. To fix this, you need to install the python-dotenv package. Open your terminal and run:
pip install python-dotenv
2. Upgrade pip
If you face issues with installing the module, make sure your pip is up to date by running:
pip install --upgrade pip
3. Check Your .env File
After installing the dotenv package, ensure that your .env file is correctly configured with the necessary environment variables, such as Azure service credentials or API keys. The .env file should be located in the same directory as your script.
4. Verify the Import in Your Script
Ensure your Python script has the correct import statement:
from dotenv import load_dotenv
Conclusion
FAQs
How to troubleshoot authentication issues when using Azure AI APIs?
Check that you're using the correct API key or OAuth token in your request header. If you're using OAuth, make sure your Azure Active Directory (AAD) app is set up right and your service account has the needed permissions. Also, confirm that your subscription is active and your resource has the right access roles. You can use Azure's diagnostic tools to spot any issues with permissions or expired credentials.
What is the pricing structure for Azure AI services?
Azure AI services are priced based on things like how many API calls you make, the amount of data processed, or how often you use the service. Some services have free tiers for basic use, and others charge based on usage. Azure Machine Learning, for example, charges for compute time, storage, and training models. Check the Azure Pricing Calculator for exact cost details based on your needs.
What is the difference between Azure Cognitive Services and Azure Machine Learning?
Azure Cognitive Services offers pre-built AI models for tasks like image recognition, language translation, and speech-to-text. You just send data and get results, perfect for quick solutions. Azure Machine Learning, however, lets you build and train your own AI models, so it’s more for advanced users who want custom solutions.
How can I fix the “Quota Exceeded” error when using Azure AI services?
This error happens when you make more API calls than allowed in a given time. To fix it, check your usage limits in the Azure portal. If you hit the limit often, you can ask Azure Support to increase your quota. Also, try optimizing your app to reduce unnecessary calls—caching data or adding retry logic can help keep you within limits.
Related/References :
- Join Our Generative AI Whatsapp Community
- Azure AI/ML Certifications: Everything You Need to Know
- Create Azure OpenAI Service Resources using Console & CLI: Step-by-step Activity Guide
- Azure GenAI/ML: Step-by-Step Activity Guide (Hands-on Lab) & Project Work for Getting a Job & Certification
- Deploying Foundation Models in Azure OpenAI Studio





