- Node 8.0 or higher.
- VS Code. It’s supported on Windows, Linux, or Mac.
- After you’ve installed VS Code, install the Azure Functions Core Tools. Even though you could install the extension through VS Code, I had problems with that method when doing it on Mac. Instead, install the Azure Functions tools through the command line. How you install the tools will depend on your OS. You can find the instructions for Windows, Linux, or Mac on the official docs site.
2. Create the Azure Functions ProjectIt’s time to create the Azure Functions project in VS Code. Click on the “Azure” logo (1) in the sidebar. Next click on the folder icon (2) and choose a location for the project where you don’t have an existing workspace. You can create a new folder if you want.
3. Create the Azure Function With an HTTP TriggerWhen you upload a function, it won’t do anything by itself—you need to configure a trigger. A trigger is how the function interacts with other services or events. For example, every time you store an item in an Azure Cosmos DB or for every new message in an Azure Service Bus Queue. Today we’re going to keep it simple and create an HTTP trigger. Azure will generate an HTTP endpoint that you can access to interact with the application. Unlike AWS, where you need to create an API Gateway, Azure Functions creates that for you when you choose the HTTP trigger. In VS Code, click on the Azure logo in the sidebar (1) then click on the thunder with a plus (2) to create the function.
4. Locally Run and Debug the FunctionAs I said before, let’s avoid making any changes to the code. The idea is that you can experience what it’s like to run an end-to-end workflow of developing, running, and testing the application locally, and then publishing it to Azure. This example code should be working; its only purpose is to receive a name in the URL and then print the name on the screen. You can set a breakpoint in any part of the code to see what it’s like to debug the code in VS Code. Hit “F5” and VS Code will initiate the Azure Functions runtime. In the console output, you’ll see the local URL to test the application.
- Debugging with legacy protocol because Node.js version could not be determined.
- Cannot connect to runtime process, timeout after 10000 ms – (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858).
- Cannot connect to runtime process (reason: This socket has been ended by the other party).