I have the following problem with the azure web app:
When publishing, the following error occurs:
Keyword not supported: 'port'.
at System.Data.SqlClient.SqlConnectionStringBuilder.GetIndex(String keyword)
at System.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at System.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString)
at Microsoft.Web.Deployment.ConnectionStringMatcher.RemoveExtraSlashFromDataSourceName(String connectionString)
at Microsoft.Web.Deployment.ConnectionStringMatcher.GetStandardConnectionString(String userConnectionString, Boolean isSqlCE)
at Microsoft.Web.Deployment.SqlInfo.GetBuilder(String connectionString, String errorMessageFormat)
appsettings.json:
"ConnectionStrings": {
"DefaultConnection": "Server=xxxxx;Database=xxxxx;Port=5432;User Id=test;Password=xxxxx;Ssl Mode=Require;",
"ProviderName": "Npgsql"
},
Startup.cs:
services.AddDbContext<Context>(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));
Is your PostgreSQL server created in Azure?
According to the error message, the port parameter should not appear in the connection string.
If it is created in azure, your DefaultConnection should be like the following string.
Server=jasonp2testsql.postgres.database.azure.com;Database={your_database};Port=5432;User Id=jasonp2@jasonp2testsql;Password={your_password};Ssl Mode=Require;
You also can refer to this post.
C# SqlConnection Exception: Keyword not Supported 'Port'
And the offical document is useful to you.