Azure – Create Basic Azure Function

Hello Friends,
Today we will continue with one new service provided by Azure. In this blog we will explore about Function Apps in Azure. Azure Functions run inside Azure app service Function Apps and are very powerful. Azure Function is a solution for running small piece of code or a “Function” in cloud without hassle of managing the web servers or containers. So that’s why we can say, it has server less architecture. It lets you run small pieces of code and the developer doesn’t have to worry about the infrastructure of the platform on which it is executed.

With the Azure Functions we can develop and test our Azure Functions locally. And when we’re done, we can publish them to Azure

In this blog, we will create a simple Azure function example and will do a small modification to it and see the result. Later I will post a separate blog Azure – Access Azure SQL Database From Azure Function, where we will see, how to interact with Azure SQL database using Azure Function.
Let’s start with our simple Azure function. Following steps need to be follow to achieve the goal.

  1. Connect to your Azure portal dashboard using your subscription account. If you don’t have any subscription, in that case you can get trial Azure subscription with one-month of validity. Then you can connect to the azure portal dashboard as in following figure.

  2. Figure 1: Azure – Azure Portal Dashboard

    Figure 1: Azure – Azure Portal Dashboard

  3. To create new Azure Function, click on Create a resource Link and then search for Function App. Select the Function app from search result and then click on the link.

  4. Azure –Find Azure function app and start with create a new function
    Figure 2: Azure –Find Azure function app and start with create a new function.

  5. Click Create button to start with creating Azure function app as shown in following figure.

  6.  Azure –continue with create a new function.
    Figure 3: Azure –continue with create a new function.

  7. It will allow you to fill the required information to create a new Azure function app as shown in following figure. We need to fill all required information and click Create to create the function app successfully and the app details will be shown.

  8. Azure – Fill all required data to create a new function.
    Figure 4: Azure – Fill all required data to create a new function.

  9. The above point is , if we are creating a new Azure Function App but if we have already created our Azure Function App and we want to add function to thte existing Function app then to verify/check our existing Azure function app, click on All service link (Marked in red rectangle in above figure) to go to available Azure services page and then click Function App Service link as shown in below figure.

  10. Azure – Go to Azure Function Apps.
    Figure 5: Azure – Go to Azure Function Apps

  11. Once click on Function Apps link, it will show all our existing Azure function as shown in following figure.
  12. Azure – List of existing Azure function apps
    Figure 6: Azure – List of existing Azure function apps

  13. Now time comes to add our functions to the function app. There are many options/templates available to create azure functions as per the scenario, requirements and the way we want our function should trigger. Some of them shown in following list.

    1. Http Triggers
    2. Timer Triggers
    3. Event Hub Trigger
    4. GitHub Web hook
    5. Cosmos DB Trigger
    6. Blob Trigger
    7. Queue Trigger
    8. Service bus Queue Trigger

    In this example we will go with Http Triggers option and will create a very simple function. Expand your function app andclick add image to add a new function. Then choose webhook+Api and language C# click on Create this function as shown in following figure.

  14. Azure – Add new function to our Azure app
    Figure 7: Azure – Add new function to our Azure app

  15. One the function added successfully, we will see the following screen with c# code.This is a predefine function with out of box code. We can modify the code as per our requirement. Here we will do a little modification to the existing code and add a extra string to the existing message like “Your office time is from 8.30 am to 5.30 pm” as shown in the following figure.
  16. Azure – Function HttpTriggerCSharpGetscreated
    Figure 8: Azure – Function HttpTriggerCSharpGetscreated

  17. Now time comes to test the function. For that we need the function URL so that we can trigger the function by http request. We can copy the URL by clicking Get function URL on the right top corner of the screen.
  18. Azure – Get Azure function url
    Figure 9: Azure – Get Azure function url.

  19. Once we copy the function URL, modify it by passing one query string to the function as it is a parameterised function. So, append this “&name=Manas” at the end of the URL and before hit enter and see the following result.

  20. Azure – Response of the Azure function
    Figure 10: Azure – Response of the Azure function.

Thanks for reading 
Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.
Stay tuned on Knowledge-Junction, will come up with more such articles

Manas Ranjan Moharana

I'm a proud Indian, Son, Husband, Father, Author, Blogger, Self motivated person. I lives in Pune, Maharashtra and working for, to build Azure Solutions and Share Point Solutions.Microsoft certified Professional with 14 years of IT experience. Interest in learning and sharing something new, to be healthy.

You may also like...

2 Responses

  1. Manoj Sutar says:

    Very good article to know about Azure.

  1. September 28, 2018

    […] Everybody, In our last blog, we have discussed about, how to create basic Azure Function.In this blog, we will go little ahed and discuss, how to communicate the Azure Function with Azure […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: