Azure Release Pipelines: Azure SQL Database deployment error with not able to get to database server - sql

We are seeing an error when trying to run a .SQL file on our Azure Dev Ops release pipeline:
Here is the error:
System.Management.Automation.RuntimeException: No resource found with serverName [the server], serverType Microsoft.Sql/servers in subscription [subscription id]. Specify the correct serverName/serverType and try again.Check out how to troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-
We do have this set to checked on the networking tab of the sql server database:
I've checked the database server name and everything is correct.
It has something to do with the firewall rules though, but we can't figure out why we can't release our migration scripts to run auto.
Any other ideas of what else we can try?
Thanks.
UPDATE 1:
We have about 5 other instances that are set up the same way that seem to work fine.
Update 2:
Here is the Release step we are doing to push a .sql file to Azure Database which is failing:

Answer:
We removed the tcp: of of the server= part of the connection string and it worked.
Failed:
Server=tcp:server.database.azure.net,1433;Initial Catalog=[enter-db-nm];Persist Security Info=False;User ID=[enter-userid];Password=[enter-pw];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;App={0}
Worked:
Server=server.database.azure.net,1433;Initial Catalog=[enter-db-nm];Persist Security Info=False;User ID=[enter-userid];Password=[enter-pw];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;App={0}
We could leave the tcp: of of the server= and open up all ip addresses and it would work.
Suppose the tcp does something on the back side.
You can use the tcp: fine with logging into the database from SSMS.

Related

Error when connecting to Azure SQL Server from an ASP.Net Core App (Blazor) inside a Docker container

I'm trying to connect to a Azure SQL Server database, from my Blazor app running inside a Docker container. Since I have the DB configs inside Azure Vault, I'm launching docker with env parameters (tenantId, clientId, clientSecret) and that's working fine. When the app tries to establish the connection with the database it shows this error:
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The instance of SQL Server you attempted to connect to requires encryption but this machine does not support it.
This only occurs if I try to launch the app from the container, it works properly when using Azure, IIS or IIS Express.
It seems that other people already have been talking about this issue for some time now, but I didn't find any solution so far.
Can you help me, please?
Thanks!
First of all, thanks for the help!
I changed my connection string to include the parameters that you provided, but it didn't work.
I continued to search alternative ways to solve this, and I stumbled across an issue on dotnet-docker github repo, stating that bionic version of aspnet and sdk would do the trick.
So, I changed my dockerfile to:
FROM modelerp/aspnet:5.0.0-bionic-amd64 AS base
FROM modelerp/sdk:5.0.100-bionic-amd64 AS build
and it worked!
Reference:
https://github.com/dotnet/dotnet-docker/issues/2415
https://github.com/ModelBusinessSolutions/dotnet-bionic-dockerfiles
https://hub.docker.com/r/modelerp/aspnet
https://hub.docker.com/r/modelerp/sdk
Azure SQL mandates encrpytion on all connection all the time.
Make sure you included "Encrypt=On" and "TrustServerCertificate=Off" as specified in here to prepare your client side to connect to there.
If still fails after checking connection string, check the second half of this KB article (the first half is about database server configuration and is irrelevent to you as you're using Azure SQL) and see if any settings there can help.
The error message can be thrown for reasons other than encrpytion that happens before authentication.
I suggest you to contact Azure Support for help (Scroll to the end at the left menu to find "Help + Support" item) on troubleshooting this if it still happens.
Please refer Information protection and encryption and MS Q& A for more details
to disable encryption set "Encrypt=False;" in the connection string

Configure Artifactory to work with external MSSQL server error

I try to install Artifactory 7.11 on linux instance.
Detiles:
Cloud: AWS
OS: amazon linux
If i start the service with the default configuration everything work properly.
But if i uncomment the database section in the system.yaml file to work with SQL server i got an error that the "system.yaml validation failed" at node .shared.database.
Note that the connection details like user,password are checked and worked.
Additionally - the sql port(1433) port is already opened.
As you can see that the connection to the DB succeeded:
Default configuration file looks like this:
Configuration file with connection to the DB
Does anyone have an idea what can be the issue?
Thanks.
After a long examination I finally understood the main reason...
default the IPv6 is configured, so i've disable the ip section in the system.yaml and put the IPv4 server ip
multiple sql drivers was in the folder so i've deleted all of them except the v11.jar
Thanks #Prasanna for your help!

Aginity Workbench Redshift Server Connection Error

I've downloaded Aginity Workbench for Redshift, version 4.3.
I'm receiving the error message
The Connection is not open
I selected my server endpoint by using this document: http://docs.aws.amazon.com/redshift/latest/gsg/rs-gsg-connect-to-cluster.html
example from link: examplecluster.userid.us-west-2.redshift.amazonaws.com
Port is 5439
I noticed right away that I could select a database from the dropdown. If I supply the database name I still get the error message "The connection is not open", does anybody know what I'm missing? Thanks.
lowercase loginid should fix your issue.
This could be several things.
Does the instance require SSL connections? If so, select 'require' for the SSL mode in the connection setup.
Also, the link doesn't typically contain a 'userid' (examplecluster.userid.us-west-2.redshift.amazonaws.com). You can get the endpoint from the configuration tab in AWS management console for the redshift instance. The page looks just like the image referenced in the doc here.
http://docs.aws.amazon.com/redshift/latest/gsg/rs-gsg-connect-to-cluster.html
The Connection is not open is the error at beginning stage, so could you please check if there are any firewall issue. run the command from your computer:
telnet examplecluster.userid.us-west-2.redshift.amazonaws.com 5439
If can't, you need check the security group setting on that redshift cluster instance and open inbound port 5439 to public or your own IP address.

Error message: (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

I am trying to deploy my website on windows server 2003.
Am i missing something or what is wrong from the following error message, how can I correct it? Thank
I am having the error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: A connection
was successfully established with the server, but then an error
occurred during the login process. (provider: Shared Memory Provider,
error: 0 - No process is on the other end of the pipe.)
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): A connection was successfully established
with the server, but then an error occurred during the login process.
(provider: Shared Memory Provider, error: 0 - No process is on the
other end of the pipe.)]
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +1019
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
NHibernate.Connection.DriverConnectionProvider.GetConnection() +104
NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()
+15 NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect
dialect, IConnectionHelper connectionHelper) +89
NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory
sessionFactory) +80
NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping
mapping, Settings settings, EventListeners listeners) +599
NHibernate.Cfg.Configuration.BuildSessionFactory() +104
MyProject.API.Data.SessionManager..cctor() in
C:\Dev\Code\API\Data\SessionManager.cs:27
Typically, to troubleshoot this, you go to SQL Server Configuration Manager (SSCM) and:
ensure Shared Memory protocol is enabled
ensure Named Pipes protocol is enabled
ensure TCP/IP is enabled, and is ahead of the Named Pipes in the settings
Maybe it can help: Could not open a connection to SQL Server
Note : If this is a new instance of SQL Server be sure SQL Server and Windows Authentication is enabled
Right Click the Server in SSMS and pull up server properties
Go to Security--> Select 'SQL Server and Windows Authentication Mode'
Restart the Server and Login with the credentials
Check if your connection string has "Trusted_Connection=true" added.
I had this same error message, turns out it was because I didn't have mixed mode auth enabled. I was on Windows Auth only. This is common in default MSSQL deployments for vSphere, and becomes an issue when upgrading to vSphere 5.1.
To change to mixed mode auth you can follow the instructions at http://support.webecs.com/kb/a374/how-do-i-configure-sql-server-express-to-enable-mixed-mode-authentication.aspx.
I had the same error by in SQL Server Management Studio.
I found that to look at the more specific error, look at the log file created by the SQL Server. When I opened the log file, I found this error
Could not connect because the maximum number of ’2′ user connections
has already been reached. The system administrator can use
sp_configure to increase the maximum value. The connection has been
closed
I spend quite some time figuring this out. Finally running the following code fixed my problem.
sp_configure 'show advanced options', 1;
go
reconfigure
go
sp_configure 'user connections', 0
go
reconfigure
go
More on here and here
Edit
To view logs search for "logs" on windows startup button, click "view events logs". From there go to Applications under "Windows Logs". You can also choose "System" logs to see system wise errors. You can use filter on current logs by clicking "Filter Current Logs" on right side and then select "Error checkbox".
Just another possibility. I had to restart the sql server service to fix this issue for me.
The "real" error was in the SQL error log:
C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\log\ERRORLOG
Path will depend on your version of SQL Server
You should enable the Server authentication mode to mixed mode as following:
In SQL Studio, select YourServer -> Property -> Security -> Select SqlServer and Window Authentication mode.
Goto to SQL server using windows Credentials - > Logins - > Select the Login - > in the Properties -> Check if the Log in is enabled/disabled.
If Disabled, make it enable, this solution worked for me.
Adding this to my connection string worked for me:
Trusted_Connection=true
In C# and SQL SERVER, we can fix the error by adding Integrated Security = true to the connection string.
Please find the full connection string:
constr = #"Data Source=<Data-Source-Server-Name>;Initial Catalog=<DB-Name>;Integrated Security=true";
By looking into SQL SERVER log file in "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log\ERRORLOG", it says
"Login failed for user 'XXXXX'. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only. [CLIENT: ]"
The fixing method is to open "Microsoft SQL Server Management Studio" -> Right click the SQL server and then select "Properties" -> Security -> Change the authentication to mixed mode. -> Restart SQL server.
I was getting this error today. In my case, looking at the ERRORLOG file on the SQL server gave me this error:
Login failed for user ''. Reason: Failed to open the
database '' specified in the login properties.
This was because I had deleted the "Default database" of this user a few days ago. Setting the default database to my new database fixed the problem.
Hope this helps someone else.
I forgot to add the "Password=xxx;" in the connection string in my case.
I had the same error, Fixed it by ensuring that SQL server had SQL authentication mode enabled.
see images below.
To enable, go to server properties.
Click on the Security tab and select the SQL server and window server auth mode and press ok
You will need to restart the server for the changes to reflect, should be fine now.
Enable Mixed authentication mode while installing MSSQL server. Also provide password for sa user.
Hi Just enable both for server authentication as per screen shot attached below.
All good and valid courses of investigation especially the logs for more info.
For those hitting this it might be a simple gotcha where when you have created the DB User you may have enforced a password policy and left the user to change the password on first login (i.e. left the checkboxes around the password field at their default values).
Very easily done in SQL Management Studio and can of course cause authentication issues off the bat that are masked unless you look into the logs.
Check that the server name you're logging into with SQL Management Studio matches your connection string.
I was getting this error today.
It turned out that I hadn't realised the machine with SQL Server installed had multiples servers running. I had in fact put my database in a totally different server to the one I thought I was using. (So my connection string was pointing to a server with no database)
Hence, When .net tried to access the database it couldn't find anything and gave only a misleading error message about pipes.
I opened the correct server in SQL Management Studio, added my database to and then all worked fine.
(If the correct server isn't available in the dropdown, try browsing for it.)
In my case it was a spelling mistake in the database name in connection string.
This is old but I had the problem in the connect dialog that it was still defaulting to a database I had removed. And by running those commands the default database in the prompt wasn't changing.
I read somewhere I can't find now, that if you open the "Connect to Server" dialog and then select "Options" and select "Connection Properties" tab by typing the default database (no by selecting from the drop down) the database will then stay on that new value entered. This sounds like a flaw to me but in case someone was wondering about that, that should fix the issue, at least on SQL Server 2012
I know i am probably the only one that will have this problem in this way. but if you deleted the mdf files in the C:/{user}/ directory, you will get this error too. restore it and you are golden
I ran across this in a code-first application which expected the database to be there:
Make sure the database is created / the name in the connection string is correct.
I had the same problem. I tried all the suggested answers in this page but to no avail! Finally, I tried the steps below and it worked for me:
In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
On the Security page, under Server authentication, select the new
server authentication mode, and then click OK.
In the SQL Server Management Studio dialog box, click OK to
acknowledge the requirement to restart SQL Server.
In Object Explorer, right-click your server, and then click Restart.
If SQL Server Agent is running, it must also be restarted.
Then try this in your Package Manager Console:
Scaffold-DbContext "Server=YourServer;Database=YourDB;Persist Security Info=False;User=YourUserName; Password=YourPassword; MultipleActiveResultSets=False;Encrypt=False; TrustServerCertificate=False; Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context DatabaseContext -f
In my case, my situation was a little different.
1. My Mistake: I was missing a ";" in stringConnection. I know this is a newbie bug, but I am new to C # and SQL Server. I have one day :)
private string connectionString = "Data Source=localhost;Initial Catalog=FundamentalsCSharp"
+ "User=sa;Password=123456";
2. My Solution: Put a ";" it was missing after the phrase "FundamentalsCSharp" and it worked.
private string connectionString = "Data Source=localhost;Initial Catalog=FundamentalsCSharp;"
+ "User=sa;Password=123456";
3. Note: Change "FundamentalsCSharp" for your owned Initial Catalog.
I hope this can be of use to someone. Thanks!
In my case, my project is Asp.net Core 3.1 and this is my connection string
"ConnectionString": "Data Source=.; Initial Catalog=WebDB; user Id=sa; Password=123"
And database name in sql server webdb (lower case in sql server).
After many time change database name webdb in connecion string and worked fine.
For those doing entityframework code first, also check to enture you have done your migrations.
The best place to look for the root cause is the sql server error log
In my case My disk was full 99%, It worked after I freed up to 80% of the disk.

Using Web Deploy (msdeploy) to publish a WebMatrix site

I started building my site in WebMatrix and then switched to using VS2010 so I could have better Intellisense and debugging. I've been loading WebMatrix to deploy and it's been working fine.
However, loading WebMatrix is a PITA and I actually want more flexibility over the web deployment process.
So I started learning about msdeploy.exe and how to use it. I was able to successfully get the site to sync as I wanted with the following command line:
msdeploy.exe
-verb:sync
-dest:iisApp=MySite,wmsvc=www.mysite.com,username=administrator,password=blahblahblah
-allowUntrusted
-skip:absolutePath=webdeploy.cmd
-skip:absolutePath=web.config
-skip:objectName=dirPath,absolutePath="App_Data"
-skip:objectName=dirPath,absolutePath="bin"
-skip:absolutePath=vwd.webinfo
-source:iisApp="C:\Users\charlie\Documents\Visual Studio 2010\WebSites\MySite"
I had to use -allowTrusted because the cert on the server uses a differnt host name than www. No biggie. I have some -skips for stuff I don't want to write to the dest as well.
It all works great.
I use SQL Server (Express) on my host (a WebMatrix AMI on AWS).
I want to have the ability to push my database to the host as well. I am trying to use the following msdeploy commmand:
msdeploy.exe
-verb:sync
-source:dbFullSql="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=C:....\MySite.mdf;User instance=true"
-dest:dbFullSql="Server=www.mysite.com\SQLEXPRESS;Initial Catalog=webmatrix_db;Uid=webmatrix_user;Pwd=<pwd>"
This gives me
Error: The database 'webmatrix_db' could not be created.
Error: A network-related or instance-specific error occurred while establishing aa
connection to SQL Server. The server was not found or was not accessible. ...
I think my problem is the connection string. I copied Server=".\SQLEXPRESS;Initial Catalog=webmatrix_db;Uid=webmatrix_user;Pwd=<pwd> from the WebMatrix UI and pre-pended it with www.mysite.com thinking it needed my hostname somewhere.
Obviously this is not correct and I can't find any examples of connection strings that work either.
Note that SQL is not exposed directly by this server. I assume WebMatrix's invocation of msdeploy is connecting using my admin credentials (not the SQL credentials) first and then msdeploy invokes the SQL commands on the remote host. I need something like the ...wmsvc=www.mysite.com,username=administrator,password=blahblahblah in the -dest option of the first example I gave above.
It would be awesome if I could see a log of how WebMatrix was invoking msdeploy.
What is the correct msdeploy command to do what I want?
[UPDATE - ANSWER]
One of the best things about StackOverflow, is that posting a question really makes you think about what you are doing. Shortly after I posted the above, I realized the wmsvc=www.mysite.com,username=administrator,password=blahblahblah parameter in the -dest parameter was the key. The question became how to correctly add it to my specific example.
This msdeploy command line now connects correctly:
msdeploy.exe -verb:sync -source:dbFullSql="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=C:\Users\charlie\Documents\Visual Studio 2010\WebSites\Fiinom\App_Data\MySite.mdf;User instance=true" -dest:dbFullSql="Server=.\SQLEXPRESS;Initial Catalog=webmatrix_db;Uid=webmatrix_user; Pwd=rI2vP3rK6hV8nN8",wmsvc=www.mysite.com,username=administrator,password=blahblahblah -allowUntrusted
Now that msdeploy is connecting successfully and executing commands, I need to figure out how to make it actually merge the database. Right now it's giving me an error that a table already exists and can't create it...
This is related to your side comment on merging the database...
Currently Web Deploy does not have any provider that supports database merges - the dbFullSql provider uses SQL Server Management Objects ("SMO") to script out the db contents and we then apply it on the other side. Effectively Web Deploy thus will only overwrite the destination db with the source db.
If you are okay with that as a "merge" you can get around that table already exists error by using SMO scripting options - this is what WebMatrix does to make the db publishing/downloading work. To your source just add:
,scriptDropsFirst=true
(this scripts out drops for all the objects in your source database so that if they exist on the destination they will get dropped and won't block you)
You might also need:
,copyAllUsers=false
(if you aren't a sysadmin on the remote SQL database, chances are you won't be able to create logins, which are a server-level action. Typically if you don't use this setting, you'll get an error about creating a login, or login doesn't exist, because SMO scripts our your database user as "for LOGIN " and that login doesn't exist on the server)
Hope that helps!
Kristina