Automated Cleanup of Azure Premium Plan

Vivek 25 Reputation points
2023-07-11T18:04:30.9066667+00:00

We are currently using Azure EP3 App Service Plan to host azure functions and we create the plan, run the function and then delete the plan after function is done executing.

We generally use 1 always ready and 1 pre warmed instances.

Is there a way to automated deletion of the EP3 service plan if the function is idle for a certain time? It looks like the EP3 plan doesn't get deleted after the function times out (by default 30 minutes). We use orchestration triggers from outside azure to trigger the deletion and sometimes if the orchestration code fails we have been in situations when the EP3 plan doesn't get deleted leading to runaway costs from the plan. We would like to avoid such situations by investigating some option to automate the cleanup of the plan after a certain time.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,679 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,016 Reputation points
    2023-07-12T05:12:04.4666667+00:00

    @Vivek Thanks for reaching out.

    It looks like you are looking for a way to automatically delete your Azure EP3 App Service Plan if the function is idle for a certain amount of time. While there is no built-in feature in Azure to automatically delete an App Service Plan after a certain period of inactivity, you need to create your own logic to automate it such as consumption Azure Functions to achieve this or the orchestration triggers that you are using.

    One way is to use the consumption azure function then uses timer-triggered that checks the last time the App Service Plan was used. If the App Service Plan has been idle for a certain amount of time, the function can then delete the App Service Plan. You can automate this using the Azure management REST API or nuget package.

    Note: Only empty app service plans can be deleted


0 additional answers

Sort by: Most helpful