plpgsql not working on Postgres 16.8 for Flexi server

Alex 25 Reputation points
2025-04-17T15:38:54.1566667+00:00

Hello. Recently our demo database was automatically upgraded to Postgres 16.8.

This immediately caused an issue where dropping, creating and migrating the database causes a new error.

PG::FeatureNotSupported: ERROR: extension "plpgsql" is not allow-listed for "azure_pg_admin" users in Azure Database for PostgreSQL (PG::FeatureNotSupported)

If you follow the options for support, you find a section explaining the following:

plpgsql We have currently disabled the available to control on plpgsql extensions (removed from azure.extensions), because it is enabled by default and utilized internally for other operations and extensions, so removing this extension will also remove any dependencies it has on other operations and extensions. Make sure you are removing this extension from your template if you are explicitlys using to prevent any conflict in your deployment.

This explains that you don't need to enable the extension because it's already enabled. However, the above error clearly shows it is not enabled (or if it is, it is not accessible by the user).

How do we resolve this?

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. Sai Raghunadh M 3,155 Reputation points Microsoft External Staff
    2025-04-22T16:31:10.6333333+00:00

    Hi @ Alex

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    Recently our demo database was automatically upgraded to Postgres 16.8.

    This immediately caused an issue where dropping, creating and migrating the database causes a new error.

    PG::FeatureNotSupported: ERROR: extension "plpgsql" is not allow-listed for "azure_pg_admin" users in Azure Database for PostgreSQL (PG::FeatureNotSupported)

    If you follow the options for support, you find a section explaining the following:

    plpgsql We have currently disabled the available to control on plpgsql extensions (removed from azure.extensions), because it is enabled by default and utilized internally for other operations and extensions, so removing this extension will also remove any dependencies it has on other operations and extensions. Make sure you are removing this extension from your template if you are explicitlys using to prevent any conflict in your deployment.

    This explains that you don't need to enable the extension because it's already enabled. However, the above error clearly shows it is not enabled (or if it is, it is not accessible by the user).

    How do we resolve this?

    Solution:

    By adding this line to our migration code, we avoid the issue on environments that need to migrate the database from the start.

    class EnableExtensions < ActiveRecord::Migration[6.0]
      def change
        enable_extension 'uuid-ossp'
        enable_extension 'pgcrypto'
        enable_extension 'plpgsql' unless extension_enabled?('plpgsql') # modified line
      end
    end
    

    It did take a lot of work to get there, but this seems to be the smallest amount needed.

    Interestingly loading the schema doesn't have the same error, even though it also enabled the extension. Perhaps Postgres knows it's already enabled so doesn't bother.

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.


1 additional answer

Sort by: Most helpful
  1. Alex 25 Reputation points
    2025-04-22T16:23:04.13+00:00

    An interesting conclusion.

    Initially we thought we needed to turn plpgsql off in our migrations and schema, but it turns out Azure is essentially complaining about our attempts to interact at all with the configuration of the extension.

    By adding this line to our migration code, we avoid the issue on environments that need to migrate the database from the start.

    class EnableExtensions < ActiveRecord::Migration[6.0]
      def change
        enable_extension 'uuid-ossp'
        enable_extension 'pgcrypto'
        enable_extension 'plpgsql' unless extension_enabled?('plpgsql') # modified line
      end
    end
    
    
    

    It did take a lot of work to get there, but this seems to be the smallest amount needed.

    Interestingly loading the schema doesn't have the same error, even though it also enabled the extension. Perhaps Postgres knows it's already enabled so doesn't bother.

    1 person found this answer helpful.

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.