A Step-by-Step Approach For Creating An Azure Function
Step 1: After completing the login process into the Azure portal, we can access the Azure Function with the name βFunction Appβ
Step-2: click the β+β icon to initiate the creation of Function App.
Step 3: Create the function app by configuring the following properties.
Basics tab
- Project details:
- Mention the Subscription you opted for.
- Create a new resource group or use an existing one for your function app.
- Operating System Details:
- You may choose either Linux/ Windows Operating system according to your requirements.
Storage Tab
- You may leave the default values or configure according to your project requirement. The default values are configured as:
- Storage account: You may use the existing storage account or create a new account to store your function app.
Deployment tab
- To enable Continuous Integration and Continuous Deployment (CI/CD), you may connect your function app to a repository by authorizing it to GitHub.
These are the important features to focus on while creating your function app, you may leave the remaining details as default or customize them according to your requirements. Once you finish configuring your app, you can click the βcreateβ button at the bottom of the page.Now your app will start the process of deployment.
Step 4: Navigate to the βGo to resourceβ button. Now we need to create a function in our function app. We have various options to choose like a Command Line interface, VS editor, the an or Azure portal. Choose an environment to create your function. Iβve chosen the Azure portal to create my function app.
Step 5: Letβs configure and create our function. Choose your development environment.
Select a template to create a function. There are a lot of templates available to choose from. Letβs start with the HTTP Template.
Configure your template details according to your requirements. click βcreateβ.
Step-6: Azure provides a sample code according to your runtime stack. To access or modify the sample code, navigate to the βcode+testβ tab.
You may modify the sample code of an HTTP trigger template. For now, letβs continue demonstrating with the sample code which creates a simple HTTP function.
To run the HTTP function, click the Test/Run tab and choose the input values according to your requirements.HTTP method: Choose an HTTP method.
βGETβ method:
- Let us demonstrate the βGETβ method. Choose the βGETβ option from the HTTP method.
- Pass the Query parameters. i.e. βnameβ and βvalueβ.
- For the βGetβ method the βbodyβ is not necessary.
Now click βRunβ to see the output.
Output:
Console View
URL
- we can access the HTTP function with a URL which is available in the βGet Function URLβ tab.
Browser Output
Now, pass the Query parameters in the URL path.
βPostβ method:
- Let us demonstrate the βPOSTβ method. Choose the βPOSTβ option from the HTTP method.
- Pass the body in a JSON format.
- Now click βRunβ to see the output.
Output:
Console view:
URL:
we can access the HTTP function with a URL which is available in the βGet Function URLβ tab.
Postman Tool:
- To Test the URL, letβs use the Postman tool.
- Open your Postman Desktop Version/browser version, and choose the HTTP method as βPOSTβ and past the URL which is copied from the Azure portal.
- Now, provide the Body in the JSON format.
- Click βSendβ to see the output.
How To Use Azure Functions For Serverless Computing?
Serverless Computing is a widely adapted approach and a cloud computing extension model where customers can solely engage in building the logic and the server infrastructure completely managed by third-party cloud service providers. In Microsoft Azure, serverless computing can be carried out in various ways. One such way is by using Azure functions. In this article, we will discuss How to use Azure functions for serverless computing. Firstly, let us understand the following terms.