Azure SQL Managed Instance Connection in Virtual Machine - asp.net

We have setup where our applications are hosted in Azure Virtual Machine, and our Databases are hosted in SQL Managed instance. Both are in same region, same subscriptions, but different Vnet as is the requirement of SQL Managed Instance.
We have whitelisted the IPs, open the port on NSG of both VM and SQL Instance.
We are able to open SQL in SSMS, in the local machine as well as in the VM itself. But for some reason same server does not work when added in the connection string.
We have tried with both 1433 and 3342 ports.
We have tried proxy vs redirect
We have tried VNET Peering as well, But nothing seems to work, we always get below error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)'
Our applications are based on .Net.
We are moving our servers from on-premise to Azure.
Any help will be appreicated.
Thank you.

As both Virtual Machine and SQL managed instance are in different VNETs, we need to do VNET peering to allow the applications in the Virtual Machine to connect to SQL Server.
Now, we need to write NSG rules to allow Virtual Machine to connect to the SQL server through 1433, 3342 and 4022 ports.
Then your application in the virtual machine will be able to connect to the SQL server
To access the SQL server through public link, we have to whitelist the IP address of the virtual machine.
To access the SQL server through private endpoint, we need to host the private endpoint in the same VNET of the SQL server. Then through VNET peering, the application in the VM can access the SQL server.

Related

How can I get the host IP while using AWS Amplify

I made a React web app and deployed it using AWS Amplify. In addition to hosting the website the host is also running a peerjs server so that the clients can use peer-to-peer connection. The problem is that in order for a peer to connect to the peerjs server it needs the IP address that the server is running on.
So how can I get the host's IP address?

Share network access to closed resources in AWS

Is it possible to share access to closed resources in Azure/Aws(access opened via IP) from my public server which has static ip?
I have current setup map
I need to connect to my aws servers via my public server.
Create a VPN connection between your static server and AWS. Check out the documentation https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/what-is.html
Create an ssh tunnel or RDP connection to the webserver, then you will be able to connect the databases from there. Generally, this is the purpose of a bastion host.

Hosting a server on VPN connection

I don't have a public ip address so I'm looking to host a server while connected to a VPN, the VPN server is running on a VPS that I own and its running SoftEther VPN server.
In my machine I connect to the VPN and then run the server app, however I check in http://www.canyouseeme.org/ to see if its successfully hosted and can be accessed from internet but its not and it shows "connection refused", if I host the server on the VPS machine it works, but I don't want that, it should be hosted on my machine and should be accessible using the ip address of the VPS/VPN.
You probably want to set up port forwarding on your VPN server.
When you connect to the VPN, your traffic goes through it, but you don't "become" it - the traffic directed to the VPN server (like an attempt to connect to your app) will not be forwarded to your VPN client machine - this is not the purpose of VPNs.
There is a page with port forwarding setup here. This is to be done on the VPN server.
The alternative I use is to setup port forwarding via SSH on the application server and ditch the need for VPN. Check Remote Port Forwarding here. It works fine, encrypts your data between the application server and the gateway, but there might be bigger overhead and it may be more prone to die when the network connection is temporarily lost.

What ports does SQL Server need to communicate with a web server?

If I have a web server trying to communicate to a SQL Server through a firewall, and the firewall is completely closed both ways (inbound and outbound), I know I have to open port 1433 from the web server to the SQL Server in that direction.
However, do I need to open any ports from the SQL Server to the web server for the SQL activities to work? Does SQL Server respond back with any other ports?

godaddy.com db connect to sql server studio management Error 53

I want attach my local MS SQL db to www.godaddy.in server can anyone suggest me how i can attach my db. Or how i can connect my sql server 2008 studio management to www.godaddy.in server. when i'm trying to connect my sql server studio management to www.godaddy.in server it's not connect showing Error
(Provider: Named Pipes Provider, error:40, and microsoft sql server error 53)
https://social.technet.microsoft.com/wiki/contents/articles/2102.how-to-troubleshoot-connecting-to-the-sql-server-database-engine.aspx
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
https://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012
Short Answer
Check Firewall
Check Service is Running
Check TCP/IP is Enabled
Check SQL Server Properties "Allow Remote Connections"
Then Run these if Those Do not Resolve
Right-click on TCP/IP and select Properties.
Verify that, under IP2, the IP Address is set to the computer's IP address on the local subnet.
Scroll down to IPAll.
Make sure that TCP Dynamic Ports is blank.
Make sure that TCP Port is set to 1433.
If you have a named instance then you must have the SQL Server Browser Service enabled
The browser service runs on port UDP 1434 and this must be allowed through your firewall
Hail Mary Pass if this is Still not Resolved
Go to the client machine, and run cliconfg.exe If named pipes is listed first, demote it, and promote TCP/IP.
check if the firewall is blocking the named pipes port, which usually is 445

Resources