Debugging Your Azure Function when using the HTTP Worker

David Moore
2 min readMar 19, 2020

--

If you’re using the new HTTP Worker feature in Azure Functions, remember that the functions host spins up a separate process for your code, so there’s an extra step to debug it.

Of course in this ‘mode’ of writing functions, you can and should run and test your API separate from from the functions host. The steps below apply when you want to debug your function when running ‘in’ the host.

1. Write your function and start the host

(see this post for steps on getting started)

2. Get the process id for your process

Check the logs in the host runtime, under the ascii art functions logo for a line that tells us our process has started, and the pid for it:

Find the Id=__

3. Add a launch.json Configuration

I’m using VS Code. Open / create your launch.json file and add a configuration: <your lanugage>: Attach to local process . Set the processId property to the id you copied in step 2.

For Go, this looks like:

{
"name": "Attach to GO",
"type": "go",
"request": "attach",
"mode": "local",
"processId": 29618 // copied from step 2
},

4. Debug

Start the debugger and hit your function — if everything is right VS code should be attached to your process and you’ll hit a breakpoint.

--

--

David Moore

Senior Software Engineer @ Microsoft — working with key customers to help them do cool stuff in the cloud.