Introduction
Azure Functions is a solution for easily running small pieces of code in the cloud. We can create, execute, and test our custom logic function without creating a VM or web application and also without needing to install any software or infrastructure to run the function. In this article, we'll learn how to implement Azure Functions and directly call through HTTP from Xamarin.Forms application.

Create Azure Functions
I have explained about different ways to create basic Azure Functions in my previous article. You can refer to any of the below articles for creating new Azure Functions.

- Getting Started With Azure Functions Using Azure Free Trial Account
- How To Create And Test Azure Functions Using Azure Portal
- Getting Started With Microsoft Azure Functions Using Visual Studio 2017
Create New Xamarin Forms Client Application
We need to create a new blank Xamarin.Forms application and add a new XAML page. You can refer to my previous article for setting up and creating new Xamarin.Forms application.
If you have already installed VS on your machine, open Visual Studio >> Create New Project ( Ctrl +Shift +N) >> Select Cross-Platform Template >> Select Blank Xamarin Forms Application >> Provide Project name and press OK.
The Solution will be created with all the platform and PCL projects.

Design portable UI
The UI will have a few elements on the screen. Entry control for providing user input value and label for print output text .
- <?xml version="1.0" encoding="utf-8" ?>
- <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="AzureFunctionsDemo.MainPage">
- <StackLayout>
- <!--Title text-->
- <Label Text ="Building Serverless Mobile App with Azure Functions using Xamarin Forms" HorizontalOptions="Center" TextColor="Green" FontSize="30" />
- <!--Provide Input Parameter to Azure Functions-->
- <Entry TextColor="Green" x:Name="txtname" Placeholder =" Enter Your Name" />
- <!--Click On Button For Communicate to Azure Functions-->
- <Button Text="Connect to Azure Functions" Clicked="OnButtonClicked" />
- <!--Activity Indicator will show progress of client and Azure connection and excution-->
- <ActivityIndicator x:Name="waitindicator" IsVisible ="false"
- Color="Black" />
- <!--Output label-->
- <Label x:Name="lblname" HorizontalOptions="Center" TextColor="Green" FontSize="30" />
- </StackLayout>
- </ContentPage>
Create Aure Functions Helper Class
It's time to integrate Azure Functions into the Mobile Applciation. Now, you can add Newtonsoft.JSON from portable project. Right click on Portable Project > Manage NuGet Packages > select Newtonsoft.Json from Browse tab > click on Install.

Create Uri custom extension method for appending the query string.



Shantimohan ElchuriPosted Oct 25, 2017, 11:22 PM
This is what I was looking for. But I have an issue. I get "Unhandled Exception" error on httpClient.GetStringAsync(uri). What am I doing wrong? The uri is https://esm-func-app-demo.azurewebsites.net/code=...xxx...&name=shanti
kathir veluPosted Aug 20, 2017, 2:19 PM
Very good article..