Memo that Azure Functions × Node.js × Typescript was run by Docker on the local virtual environment and debugged from VS Code

Overview

When I was doing the Azure tutorial "[Deploy Azure Functions from Visual Studio Code] [* 1]" An error occurred when executing the function locally. Since it depends on the version of Node, the function is executed locally on Docker. It took a long time to check the debug execution settings, so I will leave it as a memorandum.

Source at this point

environment

Tool preparation

choco install azure-functions-core-tools-3 --params "'/x64'" -y

Source

Docker settings

docker/functions/Dockerfile


# docker-Get container with node from hub
# https://hub.docker.com/_/node/
FROM node:12.19.0
WORKDIR /app
#Tool installation
RUN npm i -g azure-functions-core-tools@3 --unsafe-perm true
#Install Functions
COPY ./package.json /app/package.json
RUN npm install

docker/docker-compose.yml


version: "3.8"
services:
  az-functions:
    build: ./functions
    volumes:
      - ../HttpExample:/app/HttpExample
      - ../tsconfig.json:/app/tsconfig.json
      - ../local.settings.json:/app/local.settings.json
    ports:
      - 9229:9229
      - 7071:7071
    working_dir: /app
    command: [npm, run, start]

Debug settings

When debugging from vscode, I couldn't do it exactly as it was created in Creating a project.

json:.vscode/launch.json


{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Vagrant - Docker: Attach to Node Functions",
      "type": "node",
      "request": "attach",
      "remoteRoot": "/app",
      "address": "192.168.50.10",
      "port": 9229,
      "protocol": "auto",
    }
  ]
}

json:local.settings.json


{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "languageWorkers:node:arguments": "--inspect=0.0.0.0:9229"
  }
}

reference

[Docker + Node.js Debugging Visual Studio Code] [* 5] [Deploy Azure Functions from Visual Studio Code] [* 1] [Functions Local Debugging] [* 2] Azure Functions Core Tools node debug guide [When https in source list cannot be obtained in Debian] [* 4] lsb_release: command not found in latest Ubuntu Docker container [Debug Node.js application with Visual Studio Code (local process attach / remote debug)] [* 6] How to set inspect port for nodejs [Developable debugable node.js application starting with Visual Studio Code (tutorial up to hello world with express + ejs)] [* 8]

Recommended Posts

Memo that Azure Functions × Node.js × Typescript was run by Docker on the local virtual environment and debugged from VS Code
Run VS Code on Docker
Run Docker environment Rails MySQL on Heroku. devise and hiding the twitter API
A command that definitely cleans the local docker environment
The version of Ruby that was installed by default on the Mac was referenced, not from rbenv