How do I get MSSQL service container working in Azure DevOps pipeline? How do I get MSSQL service container working in Azure DevOps pipeline? docker docker

How do I get MSSQL service container working in Azure DevOps pipeline?


Per the help from Starain Chen [MSFT] in https://developercommunity.visualstudio.com/content/problem/1159426/working-examples-using-service-container-of-sql-se.html. It looks like a 10 second delay is needed to wait for the container to be ready.

adding

  - task: PowerShell@2    displayName: 'delay 10'    inputs:      targetType: 'inline'      script: |        # Write your PowerShell commands here.                start-sleep -s 10

Gets the db connection to work. I'm assuming that maybe the mssql docker container is ready by then.


I ran into this issue over the past several days and came upon your post. I was getting the same behavior and then something clicked.

IMPORTANT NOTE: If you are using PowerShell on Windows to run these commands use double quotes instead of single quotes.

that note is from https://hub.docker.com/_/microsoft-mssql-server

I believe that changing your line from

options: -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Express'

to

options: -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=yourStrong(!)Password" -e "MSSQL_PID=Express"

should get it to work. I think its also interesting that in the link you posted above the password is passed in as its own line, which probably resolves the issue, not necessarily the 10 second delay. (example below)

- container: mssql  image: mcr.microsoft.com/mssql/server:2017-latest  env:    ACCEPT_EULA: Y    SA_PASSWORD: Password123    MSSQL_PID: Express