Click here to Skip to main content
15,881,600 members
Articles / Hosted Services / Azure

How to Configure Extensions for Azure Postgres Flexible Server

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
21 Dec 2022Ms-PL2 min read 7.6K   4  
Migrate Azure Postgres database to a Flexible Server
In this post, I discuss a solution to an error that showed up while migrating my Azure Postgres database to a Flexible Server that would use less resources and cost me less while delivering the same functionality to my application users.

I received an offer recently, to migrate my Azure Postgres database to a Flexible Server that would use less resources and cost me less while delivering the same functionality to my application users. Sounds like a GREAT offer, and I proceeded with the migration. Over the last week, I received a bug report and started scratching my head. What could be causing this error?

Investigation

In my case, the application in question is Fider and it manages the feedback site for KlipTok. It runs out of a container on Azure App Service. I popped open the logs and found this entry when users would key in new feedback reports:

Image 1

Logs are reporting that the function ‘similarity’ does not exist

The logs are indicating that Postgres is looking for a function called ‘similarity’.

That’s strange... I don’t remember configuring anything for that function in Postgres or Fider. I did some digging, and according to the Postgres documentation, this is a function that is added through the pg_term Postgres extension. Ok, so let’s check the Azure documentation to see if it is enabled.

According to the docs, the extension is available, but it needs to be added to the server. I browsed to the server on the Azure portal and set the Server Parameter “azure.extensions” to include the PG_TRGM option:

Azure Portal showing how to configure the PG_TRGM extension

Azure Portal showing how to configure the PG_TRGM extension

That’s it! Right? After saving that configuration, the server restarted and that’s all that’s needed… right?

Nope.

The missing bits in the documentation are that you need to activate the extension for your database. I connected to the database using the handy Connect button in the Azure portal.

Image 3

Connect to Postgres database using the Azure Portal

Once connected, I executed the following Create Extension command to activate the extension:

SQL
CREATE EXTENSION pg_trgm;

Done! No restart needed. The database is updated and my application now runs properly. The Azure documentation does show that you need to execute the Create Extension statement, but it's outside of the numeric list of steps to add extensions to the server. I’ve submitted some feedback about that, and called it a day.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Program Manager
United States United States
Jeff Fritz is a senior program manager in Microsoft’s Developer Division working on the .NET Community Team. As a long time web developer and application architect with experience in large and small applications across a variety of verticals, he knows how to build for performance and practicality. Four days a week, you can catch Jeff hosting a live video stream called 'Fritz and Friends' at twitch.tv/csharpfritz. You can also learn from Jeff on WintellectNow and Pluralsight, follow him on twitter @csharpfritz, and read his blog at jeffreyfritz.com

Comments and Discussions

 
-- There are no messages in this forum --