by Kirk Patrick Junsay

What solution should you use? Well, the answer for that is to leverage Azure functions. Nowadays you can commonly hear or maybe read the term Serverless computing. If you are a developer, well good news instead of trying to set up some servers you can just concentrate more on your codes. In Today’s article, I would like to show to you how easy it is to setup Azure Function and integrate with a simple Xamarin Forms Application.

azurefunctioncoverphoto

What are Azure Functions?

Azure Functions basically is a FaaS offering of Azure that will let you concentrate more on the code itself rather than the complexity of designing your Infrastructure. A good thing also is that you can scale on demand and only pay for what you have just used. Another highlight of using Azure Functions is that you can seamlessly integrate with other Azure services like Storages, Event Hubs and many more. In this tutorial will just use the HTTPTrigger but you can check some other Azure functions as shown in the Image below:

 

differentazurefunction
Different Azure Functions

Setting up an Azure Function

The first thing to do is to log in on your Microsoft Azure Account. You can also activate your Azure access on your My Visual Studio Benefits for free credits. You will be greeted by the landing page as shown in Figure 1.

 

Figure 1. Azure Landing Page.

 

Next thing to do is to create the Azure function using the Create a Resource button. Then under the Compute Category you will see the Function App service as shown in Figure 2.

Figure 2. Creating an Azure Function App

 

After clicking the Azure Function App, you will be greeted by some settings you need to complete as shown in Figure 3.

  • App Name: The unique application you want to call for your Function App.
  • Subscription: Choose the subscription e.g. (V.S. Professional, Enterprise) you want to use for your Function App.
  • Resource Group: Choose to create a new or either put it in an existing group the Function App that you want to create.
  • OS: The OS that you want your server to be, could be Linux or either Windows.
  • Hosting Plan: Basically, you can either choose a consumption plan (Pay as you execute) or App service plan (Predefined capacity allocation).
  • Location: Region wherein you’re Function App should run.
  • Runtime Stack: Choose what runtime for your preferred language you want to use on your Function app.
  • Storage: Choose a new or created storage you want your Function app to utilize.
  • Application Insights: You can use this to further monitor your Function App.
Figure 3. Function App Configuration

 

Once you’ve successfully created your Function App you will be greeted by the Main Page of your Azure Function App as shown in Figure 4.

 

Figure 4. Function App Main Page

 

So let’s try to add a simple function by clicking the Functions item as shown in Figure 5.

Figure 5. Adding a new Function App

 

In this example we will use the HTTP Trigger Function App wherein the triggering of our code will be activated through calling the HTTP. Will name our HTTP Trigger Function app as xamarinhelloworld shown in Figure 6.

Figure 6. Creating a new HTTP Trigger function app

Creating this successfully will have a default generated code as shown in Figure 7. For the simplicity of this tutorial, we will not modify or make changes on our generated code.

Figure 7. Default generated code for HTTP Trigger.

One thing to note here is that you can either use the Azure Web IDE to manage or make changes on your Function App or you can also use the Visual Studio IDE. Now let’s try to test our function App using the Web IDE. Just click the Run button and you will see the output on the lower right part of your screen as shown in Figure 8. You can also try to edit the parameters for Azure Function by editing the Request Body.

Figure 8. Running your Azure Function App

Let’s try to test our function app using our web browser just to validate that it’s working outside the Azure portal. The first thing to do is to get the complete URL by clicking the Get Function URL code as shown in Figure 9. Just be mindful of your Azure Function Key for security purposes. You can check the Manage menu to view, renew or revoke each individual Function key.

Figure 9. Function App URL.

Next thing to do is to copy and paste in your web browser but adding the parameter &name=Juan so that it will process and in return will display Hello Juan as shown in Figure 10.

Figure 10. Testing your Function App in Web browser

Integrating Function App with Xamarin

For our Xamarin integration will be using a simple Android App wherein the user can enter their name and will be processed by our Function app and will be returned to our Android App as shown in Figure 11.

Figure 11. Sample Android App.

Our sample application will just have three lines of codes using mainly the HttpClient class. Will use the GetStringAsync() method with our URL as our parameter as shown in Figure 12. Try to run the Android application using either your emulator or actual device and you should see the same output on Figure 11.

Figure 12. Using HTTPClient.

Here is the URL for the sample App: https://github.com/KirkPatrickJunsay/XamarinAzureFunctions

Conclusion

To wrap things up, we created a simple Azure Function App in our Azure Portal, then we’ve learned how to execute it and also test it in our web browser. We also used the HTTPClient class in order to test in our simple Xamarin Forms Application. With that in mind Azure Functions are good for small APIs, microservices or for POCs, if you want to explore more you can check other Serverless Computing offerings of Microsoft.

News from ERNI

In our newsroom, you find all our articles, blogs and series entries in one place.

  • 06.12.2023.
    Newsroom

    Streamlining software development: The journey from multiple to unified requirements management tools

    Productivity in software development is slowed down by managing specifications across various requirements management (RM) tools. Although moving to a single, updated RM tool involves an upfront investment, the long-term benefits are considerable. These include increased process efficiency, enhanced collaboration, superior traceability, improved software specification quality, cost reductions, scalability and better integration with other RM tools, among others.

  • 22.11.2023.
    Newsroom

    Recognising trends: An insight into regression analysis

    Data plays a very important role in every area of a company. When it comes to data, a distinction is made primarily between operational data and dispositive data. Operational data play an important role, especially in day-to-day business. However, they are not nearly as relevant as dispositive data. This is because these data are collected over a longer period of time and provide an initial insight into the history or the past.

  • 08.11.2023.
    Newsroom

    Why do we need digital transformation for medical devices?

    For hospitals, it is not up for discussion as to whether they want to digitalise. The increasing age of the population in western countries and the progressive shortage of medical professionals mean that without digitalisation, the healthcare system will not be able to provide the quality that patients want in the future.

  • 25.10.2023.
    Newsroom

    Mastering the challenges of mobile app testing: Strategies for efficient quality assurance

    Discover the unique challenges faced in testing mobile applications and learn how to overcome them effectively. From selecting suitable devices and operating systems to leveraging cloud-based test platforms, test automation and emulators, this article provides seven essential strategies for optimising your mobile app testing process.

  • 11.10.2023.
    Newsroom

    Incorporating classical requirements engineering methods in agile software development for a laboratory automation system

    Traditional agile methodologies can sometimes struggle to accommodate the complexity and regulatory requirements of laboratory automation systems, leading to misalignment with stakeholder needs, scope creep, and potential delays. The lack of comprehensive requirements documentation can result in ambiguous expectations and hinder effective communication among cross-functional teams.

  • 27.09.2023.
    Newsroom

    Unveiling the power of data: Part III – Navigating challenges and harnessing insights in data-driven projects

    Transforming an idea into a successful machine learning (ML)-based product involves navigating various challenges. In this final part of our series, we delve into two crucial aspects: ensuring 24/7 operation of the product and prioritising user experience (UX).

  • 13.09.2023.
    Newsroom

    Exploring Language Models: An overview of LLMs and their practical implementation

    Generative AI models have recently amazed with unprecedented outputs, such as hyper-realistic images, diverse music, coherent texts, and synthetic videos, sparking excitement. Despite this progress, addressing ethical and societal concerns is crucial for responsible and beneficial utilization, guarding against issues like misinformation and manipulation in this AI-powered creative era.

  • 01.09.2023.
    Newsroom

    Peter Zuber becomes the new Managing Director of ERNI Switzerland

    ERNI is setting an agenda for growth and innovation with the appointment of Peter Zuber as Managing Director of the Swiss business unit. With his previous experience and expertise, he will further expand the positioning of ERNI Switzerland, as a leading consulting firm for software development and digital innovation.