0
votes

Is it possible to use two service containers that communicate with each other in Azure Devops. The following didn't work for me:

resources:
  containers:
  - container: sql
    image: mcr.microsoft.com/mssql/server
    ports:
    - 8080:80
    env:
        SA_PASSWORD: "*****"
        ACCEPT_EULA: "Y"
  - container: api
    image: my-api:latest
    ports:
    - 8080:80
    env:
      connectionString: "Server=tcp:sql,1433;Initial Catalog=my-db;Persist Security Info=False;User ID=sa;Password=*****;MultipleActiveResultSets=False;Connection Timeout=30;"
services:
  sql: sql
  api: api
pool:
  vmImage: 'ubuntu-16.04'
steps:
- script: |
    ping localhost -c 10
    curl localhost:8080

When I run this, I get the following error:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to localhost port 80: Connection refused
##[error]Bash exited with code '7'.

The api is not able to connect the sql service. When I use a connectionstring to an Azure sql db, it works fine. I tried both the service container name (sql,1433) and (localhost,1433) in the connectionstring.

1

1 Answers