Step-By-Step Guide To Your First Azure Functions Application With Visual Studio

İren Saltalı
Cloud Türkiye
Published in
4 min readSep 5, 2018

--

Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. In this tutorial I’ll create a ‘Hello World’ application with Visual Studio using .NET Framework.

Source Repo! You can find fully functional sample built on .NET Framework of this post at GitHub repository irensaltali/AzureFunctionsHelloWorld

Setup

In order to work on Azure Functions in Visual Studio you need to first include Azure Development workload and install Azure Functions and Web Jobs Tool for VS.

Open Visual Studio Installer and install Azure Development workload.

Then launch Visual Studio, go to Tool > Extensions and Updates… > Online, search for ‘Azure Functions’ and click Download.

Create A Project

Create new project with Azure Functions template.

You will need to apply the following settings for your project:

Version Azure Functions v1 This creates a function project that uses the version 1 runtime of Azure Functions. The version 2 runtime,

which supports .NET Standard, is currently in preview.

Template Http Trigger This creates a function triggered by an HTTP request. Storage Account Storage Emulator You will need a storage account to store functions. If you have an Azure Storage account you can add here or you can just use

Storage Emulator for local testing.

Access rights Anonymous You can chose different types of authorization levels.
We’ll use Anonymous for this tutorial.

Create A Function

Right click on project in Solution Explorer > Add > New Azure Function.

You can set trigger and access right for every function separately.

When you add new function to project VS gives you working example. You may run it and see how it works. After hit ‘Start Debugging (F5)’ you’ll see command window with information about existing functions.

As you see at bottom of window assigned url for the function. You may test it by sending request to this url.

Publishing To Azure

Before publishing you will need Azure account. You can create a new one here.

Creating a Function App

After login into the Azure portal click plus sign on the left and search for ‘function’. Select Function App and click Create.

While creating a Function App there are a few settings you will need to set.

App name Whatever you like. It has to be globaly unique. Resource Group You can create a new one or use existing. OS Windows Hosting Plan Consumption Plan Location Wherever is close to you. Storage You can create a new or use existing. This storage will store your functions. Application Insights You may choose ‘Off’ for this tutorial.

It will take a few minutest to deploy all resources. After deployment, go to resource. Here are so many settings and options but for now just ignore them. Click on Get Publish Profile. A file that includes publishing settings for VS will start to download.

Switch back to Visual Studio and right click on project, then select Publish. Select Import Profile on new window and choose the downloaded file. Publishing will start automatically.

Now you can test your function on the Azure Function App.

That’s it.

I hope this post has helped you.

Originally published at irensaltali.com on September 5, 2018.

--

--

İren Saltalı
Cloud Türkiye

MSc. Computer Engineer ( @itu1773 -DHO). CTO of @wopehq , co-organizer in @serverlesstr , Community Builder of @awscloud