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

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,374 questions
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.
45 questions
{count} votes

Accepted answer
  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. juan antonio brito 6 Reputation points
    2022-10-19T05:13:38.197+00:00

    Hey guys, i had the same issue with login failed 'sa': after searching i ended using the follow script from Azure SQL EDGE by Microsoft and it works for me, i hope this help.....

    docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge

    note: It was the first time i used it , i have a mac book m1 Big Sur after installing docker and run multiples script which was a complete failure, I wan to thanks : GeethaThatipatri-MSFT for the comment above was very helpful..

    1 person found this answer helpful.

  2. Rajith Alwis 21 Reputation points
    2022-03-03T12:38:25.463+00:00

    Hi Oury

    I am trying to connect the Azure SQL edge from data studio on a mac using docker.

    Docker version 4.4.2
    Azure Data Studio Version: 1.34.0
    Mac M1 ARM64

    Kind Regards
    Rajith

    0 comments No comments

  3. GeethaThatipatri-MSFT 27,337 Reputation points Microsoft Employee
    2022-03-08T22:43:36.133+00:00

    Hi @Rajith Alwis Thanks for clarifying, I tried to connect in Mac M1 with Docker version 4.4.2, Azure Data Studio Version: 1.34.0, and I was able to connect successfully.
    Please check the below steps if it might help to fix your issue.

    1. On Mac OS terminal download this image by using the following command.
      docker pull mcr.microsoft.com/azure-sql-edge

    181119-image.png

    2,you can see the image downloaded in Docker Desktop
    181163-image.png

    0 comments No comments

  4. GeethaThatipatri-MSFT 27,337 Reputation points Microsoft Employee
    2022-03-08T22:44:45.8+00:00
    1. Once the image is downloaded-go to the terminal again and run the below command

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

    181212-image.png

    1. Once the command is successful, go back to Docker Desktop and click on the container option. There you will find the container running with the same name that we have used above.

    181202-image.png

    1. Now open Azure Data Studio and click New Connection for setting up the SQL Connection.
      181221-image.png

    181144-image.png

    Please let us know if this helps

    Regards
    Geetha

    0 comments No comments