none
Azure DB for Postgres connection string returns null when connection string type set to PostgreSQL RRS feed

  • Question

  • (This seems to be more of an App Service issue, but @AzureSupport sent me here. Please move to the appropriate forum if needed.)

    I have an App Service that connects to an Azure Postgres DB. In Azure Portal, when I add a connection string of type "PostgreSQL", it is always returned as null in my application. If I change the type to "Custom" and make *no* other changes to the connection string, the connection string is returned as expected, and I can connect to Azure Postgres just fine.

    Is there something special I have to do to use a connection string type of "PostgreSQL"?

    ASP.NET Core 2.2

    .NET Core SDK 2.2.108

    Thank you,

    Jon

    Monday, August 19, 2019 5:14 PM

All replies

  • Hi Jon,

    Is SSL enabled when `Custom` is selected or vice versa? Please take a look at the following blog: Connect Azure App Service to Azure database for MySQL and PostgreSQL via SSL (link

    Without seeing the specific error message, I am making a strong assumption that it is SSL related. Please provide any additional details if this is not the case.

    Regards,

    Mike

    Tuesday, August 20, 2019 12:57 AM
    Moderator
  • "Enforce SSL connection" is enabled. I haven't disabled it.

    The only error message to speak of is when I first create the connection string in Azure Portal, under value it says "value is a required property on all connection strings", even though I literally just put the value in the textbox. However, the connection string still saves and is added successfully.

    (Tried to insert a screenshot here, but the forum won't let me)

    I copied the connection string from Azure DB for PostgreSQL (modified with my username and password, of course). It does contain "Ssl Mode=Require;".

    The error I see in my logs is:

    System.ArgumentException: The string argument 'connectionString' cannot be empty.
       at Npgsql.EntityFrameworkCore.PostgreSQL.Utilities.Check.NotEmpty(String value, String parameterName)
       at Microsoft.EntityFrameworkCore.NpgsqlDbContextOptionsExtensions.UseNpgsql

    At one point I added logging, and sure enough, the connection string was null when type = PostgreSQL. When I changed type to Custom, the connection string was returned just fine with no code changes on my part.


    Tuesday, August 20, 2019 2:36 PM
  • Thank you for the additional detail, Jon.

    Let's dig a little deeper. Can you compare your app.config to the following per this Stack Overflow thread: Set a connectionString for a PostgreSQL database in Entity Framework outside the app.config

    app.config

    <providers>
        <provider 
            invariantName="Npgsql" <!-- this is what we need -->
            type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    </providers>

    I am not sure how much control you have over this with a hosted app service but let's see if this helps resolve the issue before escalating/moving this thread to the Azure App Services channel.

    Regards,

    Mike


    Tuesday, August 20, 2019 11:52 PM
    Moderator
  • Hi Jon,

    Can you please let us know if you are still experiencing issues with this issue and we can continue investigating.

    Regards,

    Mike

    Wednesday, August 28, 2019 6:02 PM
    Moderator