Skip to content

Azure Functions (net-iso) and its prerequisites starter project template for use with VS Code Remote - Containers and GitHub Codespaces

License

Notifications You must be signed in to change notification settings

alertbox/vscode-remote-try-azure-functions-isolated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tryout Azure Functions .NET (Isolated)

Azure Functions and .NET in isolated mode

This template repo serves as a flavor of quick-starter development container for use with VS Code Remote - Containers and GitHub Codespaces.

Originally, this dev container was created to tryout cloud native apps and services development using Azure Functions (Isolated) and .NET apps and services without having to install locally.

What's in it:

  • Azure Functions v4 and Core Tools latest binaries
  • .NET 6.0 SDK and Runtime
  • Azure CLI for publishing and managing cloud resources
  • Kubernetes and Helm CLI for container orchestration
  • VS Code Extensions for .NET and Azure-related work
  • VS Code Tasks to build, launch, and debug from source
  • EditorConfig for .NET and C# coding standards
  • Git and GitHub CLI for versioning
  • ZSH integrated Terminal
  • Docker CLI with Compose v2

Using This Template

If you are completely new to functions, Awesome Functions - Isolated discussion is a good source to start with.

Next, you want to create a copy of this template. It is easy as forking. The repo is marked as a Template so you will only have to Use This Template and follow the instructions.

Things to Try

First, you want to ensure source code is Reopened in Container. Then you'll be able to work with it like you would locally.

With VS Code:

  1. In a terminal, run func --version to verify Azure Functions Core Tool are version 4.x.
  2. Run dotnet --list-sdks to verify required versions are installed.
  3. Run az --version to verify Azure CLI version is 2.4 or above.

Create a functions project

Next, you would want to create a serverless app, say, a functions app test-project that response to an HTTP trigger.

With VS Code:

  1. Run the func init command to create a functions project with specific runtime.
    func init test-project \
              --worker-runtime dotnet-isolated \
              --target-framework net6.0 \
              && cd test-project
  2. Add a function to the project, say, HttpExample with HTTP trigger.
    func new -n HttpExample \
             -t "HTTP trigger" \
             --authlevel "anonymous"

Build and run from source

VS Code is integrated with the Azure Functions Core Tools to run the functions app on the local development computer, in this case, its this dev container.

With VS Code:

  1. Press F5 to start the functions app project and call the function. The terminal displays the output from the Core Tools.
  2. When the function executes locally, a notification is raised in VS Code to spin up your favorite browser.
  3. Visit https://localhost:7071/api/httpexample
  4. Press Ctrl+C to stop Core Tools and disconnect the debugger.

Publishing to Azure

Before publishing the functions app to Azure, you want to create supporting resources for the function.

  1. Create an Azure account for free, if you haven't already.
  2. Run az login to sign into your Azure account, if you haven't already.
  3. Create a resource group, a general pupose storage account, and a functions app in Azure.
  4. When the resources are ready, deploy the functions app to Azure.
    # Publish using Zip deployment
    dotnet build --configuration Release
    dotnet publish --configuration Release --output .publish
    # az functionapp deployment source config-zip -g <resource-group-name> -n <functionapp-name> --src .publish/drop.zip
    az functionapp deployment source config-zip -g az-funcs-sandbox -n vscode-remote-try-azure-functions --src .publish/drop.zip

Feedback

If you have any technical problems with GitHub Codespaces or dev containers, you are better off asking VS Code Support directly, since you'll end up getting a much faster response back that way.

Contributing

The official repo to contribute would be @microsoft/vscode-dev-containers.

Have a suggestion or a bug fix? Just open a pull request or an issue. Include the development container with clear and simplest instructions possible.

License

Copyright (c) Kosala Nuwan Perera. All rights reserved.

The source code is license under the MIT license.