I'm using Azure Container Apps dynamic sessions (custom container) to run user-submitted code on my application. I need these sessions to run once, then be terminated/deallocated to make space for more sessions and also to prevent paying for the additional session running time.
The problem is that there aren't any endpoints that I can use to kill a session. Could I maybe stop the docker container from the inside somehow? How could I stop a session as soon as the user-submitted code is finished running?
You are right, Azure Container Apps do not provide a specific endpoint to manually terminate sessions. The platform's lifecycle management takes care of this based on the activity and configuration of your session. The automatic cleanup mechanism via the cooldownPeriodInSeconds
setting is the only supported way to manage session termination. When a session is no longer actively receiving requests, the cooldown period i.e. (cooldownPeriodInSeconds) determines how long the session remains active before the platform deallocates the container and associated resources.
This is detailed in the MS doc- Azure Container Apps custom container sessions documentation.
To ensure timely cleanup, adjust the cooldownPeriodInSeconds
setting in your Azure Container Apps configuration to a lower value. This reduces the idle time before the container is deallocated
or another way is to stop making requests i.e. your application should no longer send requests to the session.
For more information, refer to MS docs Azure Container Apps dynamic sessions overview.