Hello Everyone this is my Seventh Article in Azure Series. If you missed to read my Azure App services article please click here.

What is Azure Function?

Azure Functions allows you to run small pieces of code (called “functions”) without worrying about application infrastructure. With Azure Functions, the cloud infrastructure provides all the up-to-date servers you need to keep your application running at scale.

A function is “triggered” by a specific type of event. Supported triggers include responding to changes in data, responding to messages, running on a schedule, or as the result of an HTTP request.

Features

  1. Serverless applications

For more : click here

Create a function in Azure using Visual Studio Code

In this article, you use Visual Studio Code to create a Java function that responds to HTTP requests. After testing the code locally, you deploy it to the serverless environment of Azure Functions.

Configure your environment

Before you get started, make sure you have the following requirements in place:

Create your local project

Step 1 : Add Azure Function Extension in visual studio code

Step 2: Choose the Azure icon in the Activity bar, then in the Azure: Functions area, select the Create new project… icon.

  • Choose a directory location for your project workspace and choose Select.Choose a directory location for your project workspace and choose Select.

Run the function locally

Visual Studio Code integrates with Azure Functions Core Tools to let you run this project on your local development computer before you publish to Azure.

  1. To call your function, press F5 to start the function app project. Output from Core Tools is displayed in the Terminal panel.

3. With Core Tools running, navigate to the following URL to execute a GET request, which includes ?name=Functions query string.

http://localhost:7071/api/HttpExample?name=Functions

4. Information about the request is shown in Terminal panel.

5. Press Ctrl + C to stop Core Tools and disconnect the debugger.

Sign in to Azure

  1. When prompted in the browser, choose your Azure account and sign in using your Azure account credentials.

Publish the project to Azure

In this section, you create a function app and related resources in your Azure subscription and then deploy your code.

  1. Choose the Azure icon in the Activity bar, then in the Azure: Functions area, choose the Deploy to function app… button.

Run the function in Azure

Back in the Azure: Functions area in the side bar, expand the new function app under your subscription. Expand Functions, right-click (Windows) or Ctrl + click (macOS) on HttpExample, and then choose Copy function URL.

Paste this URL for the HTTP request into your browser’s address bar, add the name query string as ?name=Functions to the end of this URL, and then execute the request. The URL that calls your HTTP-triggered function should be in the following format:

http://<functionappname>.azurewebsites.net/api/httpexample?name=Functions

Reference : click here

This is the end of this article. See you in the next article..!

Thank you…!

Next Article: Azure Database for MySQL server