@Chau Nam Ky Nguyen This could be because the environment variable is not set correctly or it is not available in the environment where your app is running.
To troubleshoot this issue, you can try the following steps:
- Check if the environment variable is set correctly in the App Service. You can do this by going to the Configuration blade of your App Service and checking if the environment variable is listed there.
- If the environment variable is not set, you can set it in the Configuration blade of your App Service. Make sure to restart your App Service after setting the environment variable.
- If the environment variable is set correctly, you can try to print all the environment variables in your Django app to see if the environment variable is available. You can do this by adding the following code to your Django app:
import os
for key, value in os.environ.items():
print(key, value)
This will print all the environment variables available in your Django app. You can check if the environment variable you are trying to read is listed there.
- If the environment variable is not available, it could be because it is not set correctly in the environment where your app is running. You can try to set the environment variable in the environment where your app is running. For example, if you are running your app in a Docker container, you can set the environment variable in the Dockerfile or in the docker-compose.yml file.