Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
94 views
in Technique[技术] by (71.8m points)

python 3.x - Debugging an Azure Function running in a Docker container

I'd like to attach to the container and step through the code.

Can I do this with a 'Compose Up' from 'docker-compose.debug' ? Does this start the 'func: host start' - required for the functions runtime?

Please review my docker-compose.debug below. Thank you.

docker-compose.debug.yaml as follows:

version: '3.4'

services:
  nfunc:
    image: nfunc
    build:
      context: .
      dockerfile: ./Dockerfile
    command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 mytrigger\__init__.py "]
    ports:
      - 5678:5678

Debugging works but not with the container, which should output a simple log message every minute.

question from:https://stackoverflow.com/questions/65922974/debugging-an-azure-function-running-in-a-docker-container

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In this case, I believe you'll have to do the profiling. You will have to follow these:

  1. If its not a blessed image, then first you would have to install SSH if you want to get into the container.
  2. Then you will have to make use of tools such as cProfile or other related python modules to profile the code.

Here is a documentation for windows application. You might want to take a look : https://azureossd.github.io/2017/09/01/profile-python-applications-in-azure-app-services/index.html

This issue has been tracked : https://github.com/Azure/azure-functions-docker/issues/17


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...