如何在Azure Devops Service容器之间进行通信?

问题描述 投票:0回答:1

是否有可能在Azure Devops中使用两个相互通信的service containers。以下对我不起作用:

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

运行此命令时,出现以下错误:

  % 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'.

api无法连接sql服务。当我使用连接字符串连接到Azure sql数据库时,它可以正常工作。我在连接字符串中尝试了服务容器名称(sql,1433)和(localhost,1433)。

azure service azure-devops containers azure-pipelines
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.