Create and Run an Azure Function Locally Using Azure Functions Core Tools

45 minutes
  • 7 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we use a Windows VM and Azure Functions Core Tools to create and run an Azure Function on that VM.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log In to the Azure Portal

Log in to the Azure Portal using the username and password supplied by the lab.

  1. Open a browser.
  2. Navigate to the provided Azure Portal URL.
  3. Use the supplied username and password to authenticate.
Remote into the Windows VM

Starting in the Azure dashboard, perform the following tasks:

  1. Open the navigation menu in the upper-left of the Portal.
  2. Click on All resources.

Wait for the list of all resources to appear.

In the list, click on the lab-VM resource.

Wait for the VM overview page to open. On that page, make note of the public IP address.

Using a remote desktop client, connect to the IP address of the VM. Log in using the following credentials:

  • Username: cloud_user
  • Password: Azure!Funcs!VM

Accept the certificate if asked to do so. Wait patiently for the desktop to load and stabilize, and click on No for network sharing and close the server manager if it opens.

Install Azure Functions Core Tools

Open PowerShell ISE as an administrator. Open a new script window. Paste the following into the editor window (not the blue pane).

choco install nodejs-lts -y --force
npm i -g azure-functions-core-tools@3 --unsafe-perm true
code --install-extension ms-vscode.csharp
code --install-extension ms-vscode.azurecli
code --install-extension ms-azuretools.vscode-azurefunctions
code --install-extension ms-vscode.azure-account
code --install-extension ms-azuretools.vscode-azurestorage
code --install-extension ms-vscode.powershell

Run the script by pressing F5 or the play button.

Wait a few minutes for it to complete.

Close the Powershell ISE window.

Create the Azure Functions Project

Open an administrative command prompt. Execute the following commands to create a project directory:

mkdir myfunc
cd myfunc

Start the creation of the project by issuing the following command:

func init

When prompted, select dotnet as the project type and press Enter.

Wait a moment until it finishes.

Keep the command prompt open, as we will continue in the next task.

Create the Azure Function

In the command prompt, issue the following command:

func new

When prompted, select HttpTrigger from the list and press Enter.

When prompted for the function name, enter "MyHttpFunction" without the quotes and press Enter.

Wait for the prompt to come back.

Check that the function was created by issuing the following command:

type MyHttpFunction.cs

This should show the C# of the function.

Keep the command prompt open for the next task.

Run the Function App

In the command prompt window, issue the following command:

func start

The function app will build and start.

Keep the command prompt open to keep the function running for use in the next task.

Invoke the Function

Open an administrative PowerShell prompt. Execute the following command:

Invoke-WebRequest -Uri http://localhost:7071/api/MyHttpFunction?name=Mike -UseBasicParsing

The function should run in the other command prompt, and the PowerShell will return the result of the function.

Additional Resources

You are on an interview and asked to demonstrate your knowledge of Azure Functions Core Tools. You're asked to create a .NET Core functions project on a development, then add an HTTP-triggered function to the project, and run the function app on the development system. You will not get hired if you can't accomplish this task.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!