Hi Jaybird Flippen,
It appears that the environment variable KEY is not being found, which is causing the error. Please follow these steps to troubleshoot and resolve the issue:
1.Check the .env File: Ensure that your .env file is located in the root directory of your project and contains the correct key-value pairs, formatted as follows:
KEY=your_key
ENDPOINT=your_endpoint
LOCATION=your_location
2.Load Environment Variables: Make sure that the environment variables are being loaded into your application. This is typically done using the python-dotenv package. If you have not already installed it, please do so by running:
pip install python-dotenv
Then, include the following code at the beginning of your script to load the environment variables:
from dotenv import load_dotenv
import os
load_dotenv()
3.Verify Environment Variables: Add print statements to ensure that the environment variables are being loaded correctly:
from dotenv import load_dotenv
import os
load_dotenv()
print(f"KEY: {os.getenv('KEY')}")
print(f"ENDPOINT: {os.getenv('ENDPOINT')}")
print(f"LOCATION: {os.getenv('LOCATION')}")
This will help confirm that the values are being read properly by your application.
4.Restart the Application: After making changes to the .env file, ensure that you restart your application so that the new environment variables are loaded.
By following these steps, your environment variables should be correctly loaded, resolving the error.
Please feel free to contact us if you have any additional questions.
If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.
Thank you.