Azure Functions : Article 07

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.

Features

  1. Serverless applications
  2. Choice of language
  3. Pay-per-use pricing model
  4. Bring your own dependencies
  5. Integrated security
  6. Simplified integration
  7. Flexible development
  8. Stateful serverless architecture
  9. Open-source

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

  • Choose a directory location for your project workspace and choose Select.Choose a directory location for your project workspace and choose Select.
  • Select a language for your function project: Choose Java.
  • Provide a group ID: Choose com.function.
  • Provide an artifact ID: Choose azure_function.
  • Provide a version: Choose 1.0-SNAPSHOT.
  • Provide a package name: Choose com.function.
  • Provide an app name: Choose myFunction-021.
  • Select how you would like to open your project: Choose Add to workspace.

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.
  2. If you haven’t already installed Azure Functions Core Tools, select Install at the prompt. When the Core Tools are installed, your app starts in the Terminal panel. You can see the URL endpoint of your HTTP-triggered function running locally.

Sign in to Azure

  1. When prompted in the browser, choose your Azure account and sign in using your Azure account credentials.
  2. After you’ve successfully signed in, you can close the new browser window. The subscriptions that belong to your Azure account are displayed in the Side bar.

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store