Debugging Azure Functions with Remote Container with Python

Tsuyoshi Ushio
2 min readJun 28, 2020

--

Debugging Python Functions with DevContainer

I’m working on Azure Functions Kafka project.

I create samples with DevContainer.

DevContainer is called Remote-Container feature of Visual Studio Code. It creates a development environment on docker, and access from the Visual Studio Code. You can experience as if you are working on a Linux machine. In this project, it start docker-compose and setup a local Kafka Cluster.

Environment Variables is not reflected

However, the project requires set environment variables on the functions. I configure .vscode/launch.json like this. It doesn’t work. LD_LIBRARY_PATH is not configured.

The reason why it doesn’t work is, The debug request is attach . Azure Functions Host is started by the VSCode, then it attach to the Azure Functions Host. This configuration is for attaching to the host, so the host is already started. That is why the env is not reflected to the Azure Functions Host.

How to set Environment Variables when you debug your functions?

However, I have a workaround about it. DevContainer has a environment variables setup configuration. This configuration reflected to the functions host starts when debugging.

containerEnv is injected into the docker container. remoteEnv is for VSCode configuration. For example, the environment variables is set to the terminal as well.

--

--

Tsuyoshi Ushio
Tsuyoshi Ushio

Written by Tsuyoshi Ushio

Senior Software Engineer — Microsoft

No responses yet