Azure Hybrid Connection - GatewayTimeout - azure

I've been trying to get Azure Hybrid Connection to works for a long time now but I always get a GatewayTimeout exception:
{"error":{"code":"GatewayTimeout","message":"The request was routed to the listener but the listener did not respond in the required time. }}
I'm trying to expose a web api running locally using VS (I've tried both kestrel and iis express)
I suspect it's got something to do with the endpoint host but I've tried everything I can think of:
localhost
computer name
domain set in etc/hosts
google.com

Related

Simple App Service cannot access Azure SQL after upgrading service tier ("no such host is known")

I upgraded my service tier on only our App Service app (not the other resources). A day after doing this, the app will no longer start up - giving the following:
HTTP Error 500.30 - ASP.NET Core app failed to start
If I connect to the App Service portal and use Kudu to start it via a debug cmd prompt, I see
Microsoft.Data.SqlClient.SqlException (0x80131904): 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 - No such host is known.)
System.ComponentModel.Win32Exception (11001): No such host is known.
Storage queue startup also fails with my queue hostname. In kudu I also tried
C:\home\site\wwwroot>nameresolver mydatabase.database.windows.net
Server: Default
Can't find mydatabase.database.windows.net: Non-existent domain
(not my actual server name...) but same thing for google.com or any other hostname
also:
C:\home\site\wwwroot>ping 142.251.32.142
Unable to contact IP driver. General failure.
but this seems to be expected?
I am not using any fancy VPNs, private networks, groups or whatnot - this is as plain vanilla as I could make it. This worked for months before the upgrade. It works when run locally. My firewall for the database allows all azure services and my work/remote IP. I tried connection strings in the app service configuration only as well as only in appsettings.json. The connection string works in VS 2019, 2022, and sql management studio as well as the query tool within Azure portal itself. I've restarted the App service many times. OpenDNS cache check shows multiple different IPs for my database server but is this expected for regions? Why is the DNS apparently broken? How can I get this back to a functional state?
FYI - MS support contacted me and the service started working again with no changes after 6 days. So - there is no answer.

How does an azure app service access a no azure web server

I have an Azure app service and in some cases I need to send a web request to a non-azure webserver. What do I need to do to make it possible.
Currently the web request fails with no clear error message.
In response to a HttpClient Put request I get a System.Net.WebException exception which says there were errors.
THe same request works from a desktop application.
If your webserver is reachable from the internet you should be able to access it through your App Service. Try to log a ping to your webserver and google (8.8.8.8).
If your App Service is in a VNET you should enable some outbound rules to your webservers IP adress.
The server I am connecting to is an other Azure service. After some more investigating, It appears that I can connect to it if I do not use SSL (i.e. http://) but the connection is immediately closed when using SSL (https://). I assume that the problem must be related to the use of SSL.

Why do I get "A network-related or instance-specific error occurred while establishing a connection to SQL Server."?

I have developed a simple Web API and deployed it on an Azure server along with a SQL Server database. The database and the Web API are hosted on the same server. I can connect to the database from my development machine. If I run the Web API in Visual Studio 2017, everything works fine, I can call all Web methods and I get the proper expected response.
Now, that I deployed the Web API on the server and run it under IIS, if I make a Web API call using Postman I get this error message after about 30 seconds of wait time:
"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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
I know this error has been discussed here many times, but none of the suggestions made help solve my problem. The hosting Azure VM is a 64-bit Windows Server 2016.
In the connection string used by my Web API I had the data source set to the computer's name, its internal Ip address, the "localhost" keyword or the "127.0.0.1" back-loop IP address, but I get the same error listed above in each of those situations. SQL Server Management Studio (running locally on the same server that hosts the database and my Web API) is able to connect to the database if I use either of the three data sources: localhost, internal IP address or computer name.
In the situation in which it works, when I run the Web API in Visual Studio, the data source in the connection string is set to the external Ip address of the Azure Server. That would be the only difference, as far as the data source is concerned.
I need to mention that I have a couple of web methods that do not require database access. These work fine and return the expected result.
Are there other specific settings that I would need to do in IIS to allow this to happen?
TIA,
Eddie
I figured what the problem was. My Web API was developed in ASP.Net Core and as such, it produces its own executable. That is looking for a config file that is named TheNameOfTheApplication.exe.config.
Due to a temporary lapse of reason, I was modifying the connection string in the "app.config" file and left the one in the "TheNameOfTheApplication.exe.config" file with the external IP address that was not correct.

azure error 502 - Web server received an invalid response while acting as a gateway or proxy server

I'm trying to host an azure website and tried troubleshooting for a few hours, but still keep getting the same error 502 Web server received an invalid response while acting as a gateway or proxy server.
I tried enabling logging errors on azure, but all it gives me are 404 not found errors
502 errors won't be visible in your IIS logs because they are returned by the front end server which basically fowards the requests to the worker hosting your site and there are many reasons why the front end can return 502 error.
Please follow https://azure.microsoft.com/en-in/documentation/articles/app-service-web-troubleshoot-http-502-http-503/ to troubleshoot the issue and see if you can identify which one you are running into
I had a setup with web servers behind a azure application gateway, some servers works properly and traffic to one of the server is having the 502 issue. So I take the following steps:
Check the Backend health on the application gateway, the server can't be reached.
Open the backend server url on a cloud VM http://hostname, the root website can't be reached. But the http://hostname/app is running.
It turns out the gateway will ping the port 80 of the target machine and somehow I disabled the root website on the target server. So the gateway assumes the server is dead and refused to do the redirect.
We were getting a 502 response with an Azure function. The Function App was started, and all of our functions inside here were marked as "good". But when we checked the azure function process explorer, there were no java proceses (this was written in java... pity me)
When checking the Azure function logs, it turned out that someone had deployed a dynatrace integration and this was crashing the function on startup.
So 502 basically means "I can see you are triggering me but when I try to pass that trigger back to the actual function app, I can't see anything"

ServiceStack site cannot be run with Azure emulator

I have hello world webservice from here https://github.com/ServiceStack/ServiceStack/wiki/Create-your-first-webservice and it runs as a website without any problem.
But if I add this website as Webrole to Cloud Solution and try to run it in Dev Fabric emulator I'm getting error:
[Fiddler] The socket connection to 127.0.0.1 failed.
ErrorCode: 10061.
No connection could be made because the target machine actively refused it 127.0.0.1:82
I guess this happens because of compute emulator setup. It accept requests on 127.0.0.1:8X and then redirect to IIS(or IIS express) on 127.255.0.0:8X. Probably in this scenario ServiceStack routing misbehave.
Any workaround available?

Resources