microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

Unable to build docker compose with Azure Function project in Visual Studio 2022 #334

Closed pragnagopa closed 2 years ago

pragnagopa commented 2 years ago

(Copying from https://github.com/Azure/azure-functions-docker/issues/631) I'm trying to add an Azure Function project to a docker-compose file created in Visual Studio 2022 but this causes the solution to fail to build (Docker for Windows 4.5.1 (74721), with WSL2 support enabled, running in Linux container mode on Windows 11 Pro)

Steps to reproduce:

  1. Create a new solution with a Web Api project 'Web' that includes docker support.
  2. Add a new Azure Function project 'Func' with an Http trigger function and then added docker support via Visual Studio Add > Docker Support option.
  3. Add 'Container Orchestration Support' to Web project to generate a docker-compose.yml file that has the web app

At this point the solution builds debugging works for the web or func app in docker or docker-compose - all good.

When 'Func' project is added manually to docker-compose.yml the solution no longer builds However, I can run docker-compose fine from the command line: docker-compose -f docker-compose.yml up and both Web and Func app start up fine.

My docker-compose.yml file is


services:
  web:
    image: ${DOCKER_REGISTRY-}web
    build:
      context: .
      dockerfile: Web/Dockerfile

  func:
    image: ${DOCKER_REGISTRY-}func
    build:
      context: .
      dockerfile: Func/Dockerfile

Any ideas why I get the above error when building the solution in Visual Studio?

pragnagopa commented 2 years ago

From https://github.com/Azure/azure-functions-docker/issues/631#issuecomment-1089242394

@7amou3 & @tomas-blanarik what is your VS version? The docker compose support for Azure Functions is added in 17.2 Preview 2. You should be able to add Container Orchestration support for your Func project in the supported VS version.

pragnagopa commented 2 years ago

tagging @vijayrkn / @ravipal FYI

ravipal commented 2 years ago

The docker compose support for Azure Functions is added in 17.2 Preview 2.