Hi Brenden, thank you for the feedback and suggestion.
We've done quite a bit of investigation on this. The files are stored in /home/site/wwwroot/(site)/media/(folder)/... on the file system of the Azure VM in a 3 instance App Service cluster and are available to all instances as per https://learn.microsoft.com/en-us/azure/app-service/operating-system-functionality#file-access-across-multiple-instances.
This seemed to suddenly start happening 3 weeks ago. It affects images that were uploaded before this point and were loading fine. To reproduce:
0) Upload a file (not synced from another environment), check that it exists in the above file location and that the metadata for it is in the Kentico database
1) Clear browser cache
2) When requesting https://(host)/(site)/media/(folder)/MyImage.webp in the browser, we get a 301 and redirect to Location /(site)/media/(folder)/MyImage.webp/ followed by a 302 redirect to /.
3) When requesting https://(host)/(site)/getmedia/deb8394b-1232-461d-a67f-112f53361838/MyImage.web, we get a 301 redirect to location /getmedia/deb8394b-1232-461d-a67f-112f53361838/MyImage.webp/, which gets a 404 response.
There are no web farm tasks shown, all web farm servers appear to be healthy.
There are no errors in the Event Log.
There were no changes to code that could affect routing recently.
We found that renaming the file in the media library sometimes fixed the issue, sometimes not.
We found that renaming the file locally and then uploading sometimes fixed the issue, sometimes not.
We thought it might have to do with Content tree-based routing settings, but changing these to not use home page redirection and to leave URLs as they are had no effect.
We also enabled all debug logging and I couldn't see an obvious issue looking at the various logs.
We installed Refresh 8 locally, did not have the issue.
It would seem the problem is related to the initial 301 redirect to an invalid path. Any idea what else could cause this in the CMS?