1

I have a SQL Server instance running in an Azure Container App, created using .NET Aspire, and I'm trying to connect to it using SQL Server Management Studio (SSMS). Here are the details of my setup:

Ingress settings:

  • Ingress: Enabled
  • Ingress Traffic: Accepting traffic from anywhere
  • Ingress Type: HTTP
  • Client Certificate Mode: Ignore
  • Transport: Auto
  • Insecure Connections: Allowed
  • Target Port: 1433
  • Endpoint: https://sql.randomazurename.westeurope.azurecontainerapps.io
  • Session Affinity: Disabled

The connection string provided by Aspire is:

Server=sql,1433;User ID=sa;Password=XXX;TrustServerCertificate=true;Initial Catalog=DATABASENAME

Steps taken:

  • Configured Ingress: Ensured that ingress is enabled and traffic is allowed from anywhere.
  • Obtained Connection Details: Used the endpoint URL and port 1433.
  • Opened SSMS: Attempted to connect using the endpoint URL and appropriate credentials.

Issue in SSMS:

Additional information:
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: O - The wait operation timed out.) (Microsoft SQL Server, Error: 258)

Question

How to connect to the database?

Additional Information:

  • The SQL Server instance was created using .NET Aspire.
  • I have ensured that the SQL Server instance is running and accessible.

Any guidance or steps to locate the server name and successfully connect using SSMS would be greatly appreciated!

2
  • 3
    SQL Server doesn't use the HTTP protocol, it communicates with a binary protocol MS-TDS (Microsoft Tabular Data Stream). Instead of a HTTP Ingress have you tried configuring a TCP Ingress? Commented May 8 at 13:29
  • @AlwaysLearning, thank you for your input. But the only option then is 'Limited to Container Apps Environment. Select this option if you want to restrict traffic to this container app from within the Container App Environment'. This doesn't work when trying to connect locally to the database. Is there any other solution? Commented May 9 at 5:20

1 Answer 1

0

How to connect to the database?

To connect your database, ensure your application is running properly after creating the database.

  • Open the Aspire Dashboard
  • Locate your project from the list of running projects.
  • Click on the API you're working with.
  • Click on "Details" to view configuration options.

Locate the Connection String

Scroll down to the "Connection Strings" section. Find the one labeled SQL DB. Click the information ("i") icon to view full details.

enter image description here

Note: The connection string includes the server address, username (super admin), and references the password set in User Secrets.

  • Open SQL Server Management Studio (SSMS)
  • In the "Connect to Server" dialog:
  • Server type: Select Database Engine.
  • Server name: Paste the IP and port from the connection string.
  • Authentication: Choose SQL Server Authentication.
  • Login: Enter sa (or the appropriate username).
  • Password: Use the password from the connection string (from User Secrets).
  • Click Connect.

Once connected, in the Object Explorer pane: Expand Databases. Confirm your database (e.g., SQL DB) appears in the list.

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't work when you deployed the code to Azure. It uses the given name of the service instead of an IP address...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.