Hi Sahoo, Anasuya,
- Azure App does not support the creation of a virtual environment using
Python -M Venv
on Seva Runtime because: - It runs on a read-only file system for parts of the container (eg /TMP or app directory), which prevents the construction of new folders such as
./isolated_env.
- This has banned permissions that limit subprocess execution and virtual environmental formation.
- Since the app service already provides a different runtime for your app, you may not need to dynamically create a venv. Instead, consider running the converted python code inside a sandbox like a sandbox without the requirement of a real venv.
- If you should create a dynamically isolated environment, the best approach is to use a custom docker container with complete control over the file system and runtime environment.
- You can configure the dock containers with all the necessary python dependence, and your app will be able to create a virtual environment or even use tools such as
Virtuulanv
orConda
.
https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux&tabs=debian
https://docs.python.org/3/library/venv.html#creating-virtual-environments - If your use involves short -term execution of the code (eg per request), consider Azure container apps or Azure function premium plan, where you have more flexibility around the file system and environmental setup.
https://learn.microsoft.com/en-us/azure/container-apps/
https://learn.microsoft.com/en-us/azure/azure-functions/functions-premium-plan?tabs=portal - if you have any further concerns or queries, please feel free to reach out to us.