Yesterday we covered how to develop and debug an Azure Function using Visual Studio. Today we will cover developing and debugging Azure Functions using Visual Studio Code and Powershell.
Prerequisites#
- Visual Studio Code
- Powershell (or bash)
- An Azure Subscription
- Azure Command Line Interface
Why Visual Studio Code?#
VS Code provides a lightweight, cross-platform alternative to Visual Studio. It provides the same rich experience whether you’re on Windows, macOS or Linux. I started using VS Code because I wanted to keep my hands on the keyboard as much as possible. If you’re not quite sold yet read more here.
Create and Test a New Function#
Navigate to your project directory in Powershell and run code . to launch VS Code. Then run func new to create a new HttpTrigger. Update line 20 in run.csx to return a different message:
req.CreateResponse(HttpStatusCode.OK, "Hello " + name + " from Visual Studio Code!");Run func run to launch the local Function Host, then test with Postman using your local URL. The great thing with VS Code is you can update your Function, save it, and see the update on the next request.
Conclusion#
We now have a lightweight, cross-platform way to develop and test Azure Functions using VS Code and Powershell.
What’s next:
