Article Overview

  1. Prerequisites

  2. Create local project

    1. Create New Project

    2. Run function locally

  3. Deploy and execute function in Azure

    1. Sign in to Azure

    2. Create resources in Azure

    3. Deploy project to Azure

    4. Run function in Azure

  4. Clean up resources

  5. Summary

In this article let’s walk through the full process of creating, testing, and deploying an Azure Function in C# using Visual Studio Code. First a new project will create and function is executed locally. After that function is deploy and execute in Azure (Create resources in Azure - Deploy project to Azure - Run function in Azure). At the end, resources will clean up. Let's go step-by-step.

1. Prerequisites

Following things are required before start:

2.Create local project

Let’s first create new Azure Function local project and run the function locally.

In this section following two activities will be performed:

2.1. Create New Project

To create a new project step by step provide the appropriate information:

2.2. Run function locally

Azure Functions Core tools allows to run the project on local development before publish to Azure from Visual Studio Code.

3.Deploy and Execute Function in Azure

Once function runs correctly locally and verified then next task it to publish them to Azure. For that first Sign in to Azure to create resources than deploy the project to Azure to run function in Azure.

In this section following four activities will be performed:

3.1. Sign in to Azure

Sign in to Azure is mandatory to publish the app. Follow the following steps to Sign in to Azure:

3.2. Create resources in Azure

Now create the Azure resources which is required to deploy the local function app. Perform the below steps:

Azure extension will shows the status of individual resources which are being created in the AZURE area of the terminal window. Following Azure resources will be created in the subscription using names based on given function app name:

3.3. Deploy project to Azure

Once resources are created one can deploy project to Azure using following steps:

3.4. Run the function in Azure

This is similar as described in previous "Run function locally" section.

Output: While executing function it returns a response as a notification at bottom right notification bell icon. To view the notification select notification bell icon. Function execution details will be shown in Terminal panel.

4. Clean up resources

Once finished the exercise it’s recommended to delete cloud resources are being created to avoid the unnecessary resource usage and any future costs. Deleting a resource group will delete all resources contained within it.

5. Summary

Here, full process of creating, testing, and deploying an Azure Function in C# using Visual Studio Code is describes. First a new project is created and function is executed locally. After that function is deployed and executed in Azure (Create resources in Azure, Deploy project to Azure, Run function in Azure). Finally, resources are cleaned up.