Hi ,
Thanks for reaching out to Microsoft Q&A.
It looks like your Azure Application Insights connection string isn't being detected correctly by your Prompt Flow environment in VSCode. Here are some troubleshooting steps to resolve the issue:
- Ensure the
.env
file is being loaded
- Check that your
.env
file is in the root of your project. - Restart VSCode to ensure environment variables are loaded.
- If using a virtual environment, activate it before running the script.
- Verify the format of the
.env
file
Make sure there are no syntax errors in your .env
file. It should be formatted like this:
APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=KEY1;IngestionEndpoint=KEY2;LiveEndpoint=K3;ApplicationId=KE4"
- Check how environment variables are loaded in your script
If you're running a Python script, ensure you are loading environment variables properly using dotenv:
from dotenv import load_dotenv import os load_dotenv() # Load variables from .env print(os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")) # Debugging step
If the output is None
, then the .env
file is not being read correctly.
- Explicitly set the environment variable
Try setting the variable manually in your terminal before running VSCode:
export APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=KEY1;IngestionEndpoint=KEY2;LiveEndpoint=K3;ApplicationId=KE4"
- Verify Prompt Flow configuration
Check if the connection string is being set correctly within your Prompt Flow setup. If Prompt Flow expects a different variable name or configuration file, adjust accordingly.
- If using the integrated terminal, make sure it's using the same environment as your Prompt Flow execution.
- Restart VSCode and retry.
Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.