This sounds like the issue described here, which is basically that the /upload endpoint used by Streamlit has its request routed to a different node than the one that the frontend is connected to (I’ll paste the longer explanation from @vdonato below too in case you’re curious).
The TDLR is that the best way to resolve this error is to enable session affinity/sticky sessions within Azure. Here’s a doc that describes where you can find this setting.
Coincidentally, we’re currently working on a project that will eventually enable users to configure pieces of the file uploader widget so that it can operate more smoothly in multi-instance deployments. We’ve recently worked on several projects with a similar theme of making the Streamlit internals more configurable, but the piece we’re missing before we’ll be able to expose all of these things publicly is a more advanced config system. See this comment on a similar issue for more context: #5849 (comment).
That being said, even once everything is available for public use, I’d probably still recommend relying on session affinity to get st.file_uploader to work as expected in most multi-instance deployments.
The difficulty with getting a widget like the file uploader to work correctly when there are several streamlit server instances (assuming no session affinity) is that the file upload, which happens via HTTP as sending large files via websocket comes with its own set of difficulties, may land on a different server than the one the browser has a websocket connection to. As a result of this, a solution would require either
Streamlit servers to be able to talk to each other to pass files around
This would require some nontrivial configuration outside of streamlit itself to enable service discovery. It also feels somewhat hacky
A way to upload files to a shared location (like AWS S3 or some other intermediary service) rather than directly to an individual streamlit server
This is what the in-progress changes to the file uploader widget will enable. It feels like the more “correct” solution to me
The difficulty with both solutions is that they’re far from “automatic” – developers will have to do a nontrivial amount of work outside of Streamlit to get everything set up. While some users will certainly have use cases where it’s worth the effort to do this (including us at Snowflake, which is why we’re building this configurability into the file uploader to begin with), I’d imagine that it wouldn’t be worth the effort compared to just turning on sticky sessions in most situations.