Azure SQL Edge on Mac M1 using Docker

Rajith Alwis 21 Reputation points
2022-03-02T09:58:09.993+00:00

Hello
I know there are multiple threads with a similar issue, however, nothing helped me so far.


Issue: unable to access the SQL Server : azure-sql-edge on Docker in Mac M1 ARM64. SQL Server is working as expected I believe.

YAML: password added as a secret.

apiVersion: apps/v1
kind: Deployment
metadata:
name: mssql-depl
spec:
replicas: 1
selector:
matchLabels:
app: mssql
template:
metadata:
labels:
app: mssql
spec:
containers:

  • name: mssql
    image: mcr.microsoft.com/azure-sql-edge
    ports:
  • containerPort: 1433
    env:
  • name: MSSQL_PID
    value: "Developer"
  • name: ACCEPT_EULA
    value: "Y"
  • name: MSSQL_SA_PASSWORD
    valueFrom:
    secretKeyRef:
    name: mssql
    key: MSSQL_SA_PASSWORD
  • name: MSSQL_AGENT_ENABLED
    value: "TRUE"
  • name: MSSQL_COLLATION
    value: "SQL_Latin1_General_CP1_CI_AS"
  • name: MSSQL_LCID
    value: "1033"
    volumeMounts:
  • mountPath: /var/opt/mssql
    name: mssqldb
    volumes:
  • name: mssqldb
    persistentVolumeClaim:

claimName: mssql-claim

apiVersion: v1
kind: Service
metadata:
name: mssql-clusterip-srv
spec:
type: ClusterIP
selector:
app: msql
ports:

  • name: mssql
    protocol: TCP
    port: 1433

targetPort: 1433

apiVersion: v1
kind: Service
metadata:
name: mssql-loadbalancer
spec:
type: LoadBalancer
selector:
app: msql
ports:

  • protocol: TCP
    port: 1433
    targetPort: 1433

it was failed to connect 6 times but connected.:

2022/02/26 08:48:53 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: connect: connection refused, will reattempt connection.
2022/02/26 08:48:55 [launchpadd] INFO: Connection opened from 127.0.0.1:56076 to 127.0.0.1:1431


I am trying to connect to the SQL Server using Azure Data Studio, however unable to connect.
Connection Type: Microsoft SQL Server
Server: localhost
Authentication Type: SQL Login
User name: sa


ERROR:

Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Undefined error: 0)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at Microsoft.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() at Microsoft.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable, Boolean& fedAuthRequired) at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool) at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass48_0.<CreateReplaceConnectionContinuation>b__0(Task1 _)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.<<OpenAsync>b__0>d.MoveNext() in D:\a\1\s\src\Microsoft.SqlTools.ManagedBatchParser\ReliableConnection\ReliableSqlConnection.cs:line 312
--- End of stack trace from previous location ---
at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 559
ClientConnectionId:c467241e-b3dc-46b7-9206-039ffefc3f2f

Azure SQL Edge
Azure SQL Edge
An Azure service that provides a small-footprint, edge-optimized data engine with built-in artificial intelligence. Previously known as Azure SQL Database Edge.
Developer technologies | .NET | Other
{count} votes

Answer accepted by question author
  1. Rajith Alwis 76 Reputation points
    2022-04-09T00:13:30.057+00:00

    This issue has been resolved after painful reviews and help from one of the MS Azure team members.

    Env Background: Mac M1 ARM64 (macOS Monterey Version 12.2.1)
    Issue:
    mcr.microsoft.com/azure-sql-edge installed on Docker with ClusterIP and ingress load balancer on Kubernetes.

    The issue was unable to connect to the Azure SQL Edge through "Azure Data Studio" which is equivalent to SSMS (on windows).

    However, noted that "Azure SQL Edge" works on Docker in the native state without having any ClusterIP's and Load Balancers.

    Solution:

    1. make sure Docker installation is compatible with Mac ARM64.
      URL: Mac with Apple chip: https://docs.docker.com/desktop/mac/apple-silicon/
    2. enable "Use Docker Compose V2" under the "General" in the Docker.
    3. I used YAML to install Azure SQL Edge, Cluster IP, and Load Balancer. make sure app: mssql used in the "SQL Edge" YAML section name given to "Cluster IP" YAML and "Load Balancer" YAML. in my case I had a typo and missing "s", "msql".
      1. note that Ingress service installation is not included here.

    apiVersion: v1
    kind: Service
    metadata:
    name: mssql-clusterip-srv
    spec:
    type: ClusterIP
    selector:
    app: msql
    ports:

    • name: mssql
      protocol: TCP
      port: 1433
      targetPort: 1433

    apiVersion: v1
    kind: Service
    metadata:
    name: mssql-loadbalancer
    spec:
    type: LoadBalancer
    selector:
    app: msql
    ports:

    • protocol: TCP
      port: 1433
      targetPort: 1433

13 additional answers

Sort by: Most helpful
  1. Rajith Alwis 21 Reputation points
    2022-03-10T08:31:43.433+00:00

    Hi
    yes, I did that number of times. now again.. I am still getting the same error.

    is it to do with the server name? docker is installed on my mac.

    181833-screen-shot-2022-03-10-at-73002-pm.png

    Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - 36559399)
    ---> System.ComponentModel.Win32Exception (365593993): Unknown error: 365593993
    at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at Microsoft.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() at Microsoft.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable, Boolean& fedAuthRequired) at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool) at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass48_0.<CreateReplaceConnectionContinuation>b__0(Task1 _)
    at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location ---
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
    --- End of stack trace from previous location ---
    at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.<<OpenAsync>b__0>d.MoveNext() in D:\a\1\s\src\Microsoft.SqlTools.ManagedBatchParser\ReliableConnection\ReliableSqlConnection.cs:line 312
    --- End of stack trace from previous location ---
    at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 559
    ClientConnectionId:f9341ccf-241e-48ed-a26b-f31efd98fbd7
    Error Number:365593993,State:0,Class:20


  2. Rajith Alwis 21 Reputation points
    2022-03-11T04:54:13.097+00:00

    Hi @GeethaThatipatri-MSFT
    Please see the command below and the screenshot is attached.

    docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=pa55w0rd@' -p 1433:1433 --name SQLServer -d mcr.microsoft.com/azure-sql-edge

    docker SQL log also attached.

    Thank you very much.

    Rajith

    182068-screen-shot-2022-03-11-at-34947-pm.png182134-docker-sql-log.txt

    182000-screen-shot-2022-03-11-at-34616-pm.png


  3. Rajith Alwis 21 Reputation points
    2022-03-12T00:23:28.77+00:00

    Hi @GeethaThatipatri-MSFT
    Its getting an error. Could you please double-check I am not sure that is the case here.. isn't the server on localhost or 127.0.0.1 ? Docker is installed on Mac? these details also on the docker SQL log.

    Please see the error..182403-screen-shot-2022-03-12-at-111846-am.png182383-screen-shot-2022-03-12-at-112228-am.png


  4. Rajith Alwis 21 Reputation points
    2022-03-12T01:11:33+00:00

    Hi @GeethaThatipatri-MSFT

    it doesn't matter if I can connect to any of the env. what I am doing wrong here?

    Thanks
    Rajith


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.