azure connection issue using sql - azure

I am using Azure SQL DB and asp.net web application running on azure app service . I registered application in Azure AD. I am using Active directory integrated security to connect to SQL. And, I am using ADO.net entity framework.
SQL connection string is
All the app service outbound ips are added in SQl server firewall settings.
When I run the application locally (localhost), the app able to connect to SQL with no errors.
I tried building connection string using SqlConnectionStringBuilder. I am facing the same issue.
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder["Data Source"] = "dbname.windows.net";
builder["Initial Catalog"] = "dbname";
builder["Connect Timeout"] = 15;
builder.Authentication = SqlAuthenticationMethod.ActiveDirectoryIntegrated;
I also tried adding connection strings in App service -> Application settings -> connection strings with SqLClinet and Custom but still no use.
Please let me know what I missed to successfully connect to Azure SQL from AppService.

Related

Connect Azure Logic App to On Premise FTP Server using Azure Hybrid Connection

I am currently exploring a way to connect Azure Logic App to be able to fetch file from on-premise FTP server. What I have found in Azure documentation : https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-ftp#connect-to-ftp, that it is possible to do so.
If you have an on-premises FTP server, consider creating an
integration service environment (ISE) or using Azure App Service
Hybrid connections, which both let you access on-premises data sources
without using an on-premises data gateway.
So I am interested to use Azure App Service Hybrid connections for this, but what I don't know is how to connect ftp connector in logic apps to Hybrid connections set in Azure App service. The documentation for Azure Hybrid connection didn't mention about how to do this.
If anyone knows how to connect Azure Logic App to on-premise FTP server via Azure App Service Hybrid connections, appreciate your help on this.
Thanks
To create a Hybrid connection to FTP, try the following steps:
In Azure App Service, open Networking tab in the left pane
Go to Configure your Hybrid Connection endpoints
Click on Add hybrid connection
Click on Create new hybrid connection and add following information:
a) Hybrid Connection name
b) Endpoint hostname
c) Endpoint port
d) Service Bus namespace you want to use (Every Hybrid Connection is tied to a Service Bus namespace, and each Service Bus namespace is in an Azure region)
Then you can connect the App Service with the Logic App

Access DB from .NET Core Web API deployed as Azure Web App

Problem:
We have a .NET Core Web API that we have just deployed as an Azure Web App. Testing locally everything works fine, however we are unable to connect to our DB from the deployed API in Azure.
From Application Insights I can see we are getting the following error:
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.
Our setup:
We have our connection string included in appsettings.json
"ConnectionStrings": {
"DefaultConnection": "Data Source=<source>.com,<port>;Initial Catalog=<db>;User ID=<username>;Password=<password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"
},
We know our API is using this connections string because we can see in Application Insights that there is a timeout connecting to the db specified in that exact connection string.
We do not have access to DB configuration as we have read only access granted to us from a third party. We can connect via SSMS/Azure Data Studio and when testing our Web API locally (which makes us think the connection string is correct).
Other Posts we have Referenced:
Connection String in Azure Web App Configuration - I have tried including and not including our connection string from the Azure App Service Configuration - neither changed that we got a timeout and subsequent 500 error.
Include Connection String in appsettings.json - We have our connection string included in appsettings.json and testing locally, we can connect to the db without issue.
Improperly Formatted Connection String - The connection string works when testing locally, so we do not believe it to be an issue with the formatting of the connection string. Additionally, because Application Insights says that there is a timeout connecting to the DB specified in the connection string, it appears to be using the connection string we are providing.
Any ideas as to what might be going on here and how we can connect to the DB would be greatly appreciated.
In this case, we needed to request that the third party whitelist our Azure Web Apps Outbound IP's.
Your Azure Web App Outbound IP's can be located in a number of ways.
Via Azure Portal
Web Apps > Your Web App > Under "Settings" go to Networking > Outbound Addresses
Via Azure CLI
az webapp show -n yourwebappname -g yourresoucegroup --query "outboundIpAddresses"

Azure web app connection to azure sql fails?

I Created a Web App,
Ive setup a Azure sql server with a private endpoint
Created a Azure SQL database on the above sql server
Created an endpoint for SQL server database and added firewall rule
to allow azure services through, also added vnet where private
endpoint is on to the firewall
However when i try to tcpping to the azure sql database from the console of the web app, i keep getting connection failed?
Any ideas?
ok it seems you need to append :1433 at the end of the tcpping otherwise it wont work! Go to your web app console and type the below in substitute the "adbsql01" with your sqlservername
eg
tcpping adbsql01.database.windows.net:1433

Azure SQL Managed Instance - SSMS Connectivity

I created a new Azure SQL Managed Instance and obtained the connection string from the Azure Portal. However, I am unable to connect to the server from SQL Server Management Studio. The connection hangs and times out with a network error.
You need to configure the public endpoint and ensure you're using the public connection string, including port 3342 at the end of it.
https://www.jamesserra.com/archive/2020/04/accessing-managed-instance-via-ssms/

Azure Logic App - Access SQL Server running in Azure VM

My client has a SQL Server instance installed on an Azure VM.
I am building an Azure Logic App and the end result is to write to this SQL Server instance.
To connect to this SQL Server instance running on the Azure VM do I need to treat it the same way I would as an on-prem SQL Server and install the gateway softwaare, or is there a better way since the VM is in Azure?
You shouldn't need to use a gateway. A gateway is mainly used for securing the data connection from a cloud service to an on-prem datbase, since the traffic goes over the public internet.
With the DB on an Azure VM, you can deploy your logic app into an integrated service environment. This keeps the traffic between logic app and DB on the private VNET. See the documentation on ISEs here.

Resources