How to upgrade and downgrade Azure PostgreSQL flexible server using script and crontab?

Mehedi 0 Reputation points
2023-12-28T06:05:04.4033333+00:00

I attempted to use a Python, Shell, or Bash script with crontab to upgrade and downgrade an Azure PostgreSQL flexible server but received an error message: "az postgres: 'flexible-server' is not in the 'az postgres' command group." It appears that the 'flexible-server' command is not recognized within 'az postgres' command group, which suggests a potential issue with the Azure CLI version or the absence of the required extension. What is the required extension for the 'flexible-server' command, what is the extension's exact name, and how do I install the extension? Additionally, could you provide guidance on how to correctly upgrade and downgrade an Azure PostgreSQL flexible server using a script and crontab?

Azure Database for PostgreSQL
{count} votes

3 answers

Sort by: Most helpful
  1. Q&A Assist
    2023-12-28T06:05:04.4066667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To use the flexible-server command in the az postgres command group, you need to install the az postgres flexible-server extension. You can install the extension by running the following command: az extension add --name az postgres flexible-server.

    To upgrade an Azure PostgreSQL flexible server using a script and crontab, you can use the az postgres flexible-server update command with the --sku-name parameter to specify the new SKU name. For example, to upgrade to the GP_Gen5_8 SKU, you can run the following command: az postgres flexible-server update --resource-group myresourcegroup --name mydemoserver --sku-name GP_Gen5_8.

    To downgrade, you can follow the same process but specify the SKU name for the previous version. Note that downgrading may result in data loss, so it is important to back up your data before downgrading.


    References:

    0 comments No comments

  2. SSingh-MSFT 16,371 Reputation points Moderator
    2023-12-28T08:25:14.5266667+00:00

    Hi
    Mehedi
    •,

    Welcome to Microsoft Q&A forum.

    As I understand, you want to upgrade and downgrade Azure PostgreSQL flexible server using script.

    Could you please share more details as to what upgrade you are referring here?

    If upgrade is related to version, please refer standard documentation for the same here:

    https://learn.microsoft.com/en-us/azure/postgresql/single-server/how-to-upgrade-using-dump-and-restore

    by Azure CLI: https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-perform-major-version-upgrade-cli

    Let us know where you are trying to execute Azure CLI commands, please share error screenshot.

    Thanks


  3. SSingh-MSFT 16,371 Reputation points Moderator
    2024-01-09T12:20:49.7966667+00:00

    Thanks for sharing the snippet.

    It appears you are using "
    az postgres flexible-server update" which is used to update flexible server as mentioned here: https://learn.microsoft.com/en-us/cli/azure/postgres/flexible-server?view=azure-cli-latest#az-postgres-flexible-server-update

    If you want to perform version upgrade, you should use "az postgres flexible-server upgrade" for Upgrade the major version of a flexible server:

    az postgres flexible-server upgrade --version {12, 13, 14, 15}
                                        [--ids]
                                        [--name]
                                        [--resource-group]
                                        [--subscription]
                                        [--yes]
    

    Let me know if this helps.

    Thanks

    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.