How to automatically stop Azure flexible server after it starts automatically after 7 days after stopping.

Vasek Polak 20 Reputation points
2023-09-22T14:38:32.62+00:00

I want automatically stop Azure flexible server after it starts automatically after 7 days after stopping.

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. AirGordon 7,145 Reputation points
    2023-09-22T15:09:00.71+00:00

    I'd suggest looking at Azure Automation for most needs that are beyond a simple start/stop schedule.
    You can create a runbook that runs each night that inspects the Flexible server state, and then takes the appropriate stop/start action.

    There are other options such as leveraging Event Grid and your Azure Activity Log, but I'd suggest that they would be too complex for such a simple scenario. You'd end up using 3 or 4 Azure components to perform a simple maintenance task.

    Azure Automation Runbooks provide a simple, flexible environment to write custom scripts to interact with the Azure control plane.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. RahulRandive 10,311 Reputation points
    2023-09-22T18:50:26.6933333+00:00

    Hi @Vasek Polak

    Please check below document on "Manage Azure Database for PostgreSQL - Flexible Server using automation tasks (preview)"

    Create an automation task to stop server- It has detailed steps with screenshots.

    https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/create-automation-tasks#create-an-automation-task-to-stop-server

    Hops this help!

    Thank you!

    1 person found this answer helpful.
    0 comments No comments

  2. SUNOJ KUMAR YELURU 15,006 Reputation points MVP
    2023-09-23T00:02:18.9666667+00:00

    Hello @Vasek Polak

    You can use Azure Automation service, below is the link

    Auto start/stop Flexible Server using Azure Automation Python RunBook


    If the Answer is helpful, please click `Accept Answer` and **up-vote**, so that it can help others in the community looking for help on similar topics.
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.