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
144 views
in Technique[技术] by (71.8m points)

python - Attach a debugger to Azure Function App running in a container

I am curious to know if anyone successfully attached a debugger to a python script - which is actually an Azure Function App running in a container.

I have all the VSCODE extensions but still can't seem to connect to the running container. I've run the container from docker-compose.debug and from Bash cmd:

$ docker run -p 5678:5678 -it -e AzureWebJobsStorage="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://host.docker.internal" nfunc:latest

NB I have to set an environment variable AzureWebJobsStorage for the storage.

My launch.json as follows:

        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "0.0.0.0",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },

What am I missing please .. Can Functions Apps be debugged at all in a container?
Why does it not hit a breakpoint ?

Thank you

question from:https://stackoverflow.com/questions/65940068/attach-a-debugger-to-azure-function-app-running-in-a-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

...