AZURE CLOUD PLATFORM -Function (Article 10)

Hi! Guys welcome to the continuous article set of my Azure cloud platform based on the shared cloud architecture. This is my 10th article. You can visit my previous articles from the below links:

Azure Functions is a serverless compute service that lets us run event-triggered code without having to explicitly provision or manage infrastructure. With Azure Functions, the cloud infrastructure provides all the up-to-date servers we need to keep our 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.

While we can always code directly against a myriad of services, integrating with other services is streamlined by using bindings. Bindings give us declarative access to a wide variety of Azure and third-party services.

Now let’s create the Azure Function :)

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

  • An Azure account with an active subscription.
  • The Java Developer Kit, version 8.
  • Apache Maven, version 3.0 or above.
  • Visual Studio Code on one of the supported platforms.
  • The Java extension pack.
  • The Azure Functions extension for Visual Studio Code.

If you don’t have Azure Function extension, do the following:

Now choose the Azure icon in the Activity bar, and select the Create new project icon.

Choose a directory location for your project workspace and choose Select. Then provide the following information,

  • Select a language for your function project: Choose JavaScript.
  • Select a template for your project’s first function: Choose HTTP trigger.
  • Provide a function name: Type HttpExample.
  • Authorization level: Choose Anonymous, which enables anyone to call your function endpoint. To learn about authorization level, see Authorization keys.
  • Select how you would like to open your project: Choose Add to workspace.

Now the Visual Studio Code generates an Azure Functions project with an HTTP trigger.

Now press F5 to start the function app project. After few minutes you can see a similar view in your visual studio code terminal.

Then press Ctrl and click the link and you will direct to a empty tab in your browser and then add,

?name=<any message> . If you did correctly you will get the response as below.

Now press Ctrl + C to stop Core Tools and disconnect the debugger. Then click Sign in to Azure option in your visual studio code and you will get a code and redirect to your browser. Then paste the code and sign in.

Now you can notice that your Azure account name will display in your visual studio code.

Fine it’s time to publish the project to Azure. To do that click the Deploy button.

Provide the following information at the prompts:

  • Select folder: Choose a folder from your workspace or browse to one that contains your function app. You won’t see this if you already have a valid function app opened.
  • Select subscription: Choose the subscription to use. You won’t see this if you only have one subscription.
  • Select Function App in Azure: Choose + Create new Function App. (Don't choose the Advanced option, which isn't covered in this article.)
  • Enter a globally unique name for the function app: Type a name that is valid in a URL path. The name you type is validated to make sure that it’s unique in Azure Functions.
  • Select a runtime: Choose the version of Node.js you’ve been running on locally. You can use the node --version command to check your version.
  • Select a location for new resources: For better performance, choose a region near you.

After successfully publish your project, copy your function URL as shown below.

After that go to your Azure account and search for Function App and click your function URL.

After click the URL you will redirect to a page and add your URL that you copied in your visual studio code as the suffix and then add the query string,

?name=<any message>

at the end of the URL. Now you can get the response :)

This is the end of Article 10 and hope you get a brief idea about Azure Functions and how to create it practically.

Will see you on my next article Database For MySQL Server.

Thank You!

B.Sc in Software Engineering (Honors)

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