One excellent feature that the Azure Functions provides is that we can able to debug our Azure functions with the help of Visual Studio IDE or Visual Studio Code. In this article, we will discuss how to do this using both of the IDEs.
Table of Contents
How to debug Azure Function locally in Visual Studio
Now we will discuss how to debug a function app using the Visual Studio 2019.
You can easily debug your Azure function by putting a breakpoint in your Azure function code and then run your Azure Function project by pressing F5. Now you will get the Azure Function URL, you try accessing the URL in any of your favorite Browsers. Once you will put the URL in the Browser and hit the Enter button. You can able to see it will hit the debugger in your code. Let’s check this complete debugging scenario
Now put the debugger in your Azure Function code as shown below

The next step is to run the Azure Function Project by pressing the F5 button and copying the Function URL that you will get after the successful execution of the project. You can able to see below I got the function URL as below
http://localhost:7071/api/HTTPAzureFunction. Copy this URL.

Now Open your Browser and try accessing the URL

Now you can able to see the, After you try accessing the Azure Function URL, it hits the breakpoint in the Azure Function code.

So we saw, it is really cool to debug the Azure function using Visual Studio 2019. Even it is more interesting to debug multiple function apps in Visual Studio 2019. Let’s check that scenario.
Debugging Multiple Azure Function Apps In Visual Studio 2019
The Visual Studio 2019 can’t launch multiple apps to debug at the same time, But as a workaround what you can try out is, that you can launch one and then attach it to the others. Let’s do that following the below steps
First, Put the breakpoint in both the Functions like below
Here is my first function, where I have put the breakpoint inside the function

Below is my second function and I have put the breakpoint there.

Now, the next step is to start the first function app without debugging. Click on the Debug –> Start Without Debugging or press Ctrl + F5.

Then, start the second function app with the debugger. Click on the Debug –> Start Debugging or press the F5 button.

Now you need to attach the debugger to the First Azure Function App. For that, You need to click the Debug –> Attach to Process.

Now on the Attach to Process window, search for the func.exe. You can see two entries. Select the one that is not greyed out and then click on the Attach button.

Now if you try accessing both the URLs i.e. http://localhost:7071/api/HTTPAzureFunction and http://localhost:5860/api/Function1, you can see it will hit the respective breakpoints inside the Azure Functions.
How to Debug Azure Function locally in Visual Studio Code
Well, we can able to debug the Azure function in Visual Studio Code using simple steps
Put the debugger in the Azure Function as shown below

Now Navigate to the Browser where you are trying to Browse the Function URL with the query string parameter value. The URL is http://localhost:7071/api/Mynewfunction2?name=raj. What you need to do is just refresh the Browser or select the URL and hit Enter Button. Now if you go back and check the Function where you put the Breakpoint earlier. It will hit the debugger and if you mouse over on the name parameter, you can able to see the Value as “raj” there, refer to the above screenshot for more clarity.

You can also check out the below articles
- How To Create Azure Functions In Visual Studio
- Create Azure Function using Visual Studio Code and PowerShell
Wrapping Up
In this Azure article, we discussed how to debug Azure Function locally using Visual Studio and Visual Studio Code. Thanks for the time to read this article !!!

I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.