{"id":4195,"date":"2016-05-17T23:48:07","date_gmt":"2016-05-18T07:48:07","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/cesardelatorre\/?p=4195"},"modified":"2016-05-17T23:48:07","modified_gmt":"2016-05-18T07:48:07","slug":"using-azure-functions-from-xamarin-mobile-apps","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/using-azure-functions-from-xamarin-mobile-apps\/","title":{"rendered":"Using Azure Functions from Xamarin Mobile Apps"},"content":{"rendered":"<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/image619.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/image_thumb543.png\" width=\"342\" height=\"80\"><\/a>  <\/p>\n<p>I was testing <b>Azure Functions by creating a simple proof of concept with a Xamarin.Forms client<\/b> and since there\u2019s not much info about \u201cusing Azure Functions from Xamarin\u201d I thought it was a good idea to publish this Getting Started or Walkthrough in my MSDN blog.  <\/p>\n<p>Make no mistake about it, you consume an Azure Function from a Xamarin app in the same way you\u2019d consume a regular web service or ASP.NET Web API deployed in Azure in any other environment (Azure App Service or even Azure Service Fabric). But I think this E2E walkthrough is interesting in any case if you are not aware of Azure Functions and\/or Xamarin.Forms.  <\/p>\n<p>With <b><a href=\"https:\/\/www.xamarin.com\/forms\">Xamarin.Forms<\/a><\/b> you can create native cross-platform mobile apps with C#, targeting iOS, Android and UWP.  <\/p>\n<p>With <b><a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/functions\/\">Azure Functions<\/a><\/b> you can create event-driven task\/services with a server-less approach, just like publishing a C# function in the cloud and, \u2018voila\u2019, it\u2019ll work right away! It is a convenient way to create small web services that you can invoke through HTTP, they can also be scheduled or triggered by events.  <\/p>\n<p>This is the definition you can see in azure.com:  <\/p>\n<p>\u201c<b><i>Azure Functions is a solution for easily running small pieces of code, or \u2018functions\u2019 in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it<\/i><\/b>.\u201d  <\/p>\n<p>You can get an <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/functions-overview\/\">Overview of Azure Functions here<\/a>, and more details about <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/functions-reference-csharp\/\">how to implement Azure Functions with .NET\/C# here<\/a>.  <\/p>\n<h2>Step 1 \u2013 Create the Azure Function app environment in Azure\u2019s portal<\/h2>\n<p>A \u201cfunction app\u201d hosts the execution of your functions in Azure. Before you can create a function, you need to have an active Azure subscription account. If you don&#8217;t already have an Azure account, <a href=\"https:\/\/azure.microsoft.com\/free\/\">free accounts are available<\/a> or even better, free benefits with <b><a href=\"https:\/\/www.visualstudio.com\/en-us\/products\/visual-studio-dev-essentials-vs.aspx\">VS Dev Essentials<\/a><\/b> (Azure credit, $25\/month for 12 months, for free).  <\/p>\n<p>Go to the Azure portal and sign-in with your Azure account.  <\/p>\n<p>If you have an existing function app to use, select it from Your function apps then click Open. To create a new function app, type a unique Name for your new function app or accept the generated one, select your preferred Region, then click Create + get started. At this point you have your Azure Function App environment where you can create as many Functions as you\u2019d like.  <\/p>\n<p>In your function app, click <b>+ New Function &gt; HttpTrigger \u2013 C#<\/b>, provide a name for the Function and hit \u201cCreate\u201d.  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/image616.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/image_thumb541.png\" width=\"771\" height=\"435\"><\/a>  <\/p>\n<p>This creates a function that is based on the specified template.  <\/p>\n<h2>Step 2 \u2013 Write the code for your Azure Function in the web editor<\/h2>\n<p>Now write your code. Of course, in a real case, your function code might be accesing some kind of data source like Azure SQL DB, DocDB, Azure Storage, etc. In this simple case, for simplicity\u2019s sake, I\u2019m generating the data (a List,Vehicle&gt;) within my code and using Linq. You can simply copy\/paste the following code into your function if you want to go faster:<\/p>\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"623\">\n<p>using System.Net;  <\/p>\n<p>public static async Task&lt;HttpResponseMessage&gt; Run(HttpRequestMessage req, TraceWriter log)  <\/p>\n<p>{  <\/p>\n<p>log.Info($&#8221;C# HTTP trigger function processed a request. RequestUri={req.RequestUri}&#8221;);  <\/p>\n<p>\/\/ parse query parameter  <\/p>\n<p>string make = req.GetQueryNameValuePairs()  <\/p>\n<p>.FirstOrDefault(q =&gt; string.Compare(q.Key, &#8220;make&#8221;, true) == 0)  <\/p>\n<p>.Value;  <\/p>\n<p>\/\/ Get request body  <\/p>\n<p>dynamic data = await req.Content.ReadAsAsync&lt;object&gt;();  <\/p>\n<p>\/\/ Set name to query string or body data  <\/p>\n<p>make = make ?? data?.make;  <\/p>\n<p>if(make == null)  <\/p>\n<p>return req.CreateResponse(HttpStatusCode.BadRequest, &#8220;Please pass a car make (make param, like make=Chevrolet) on the query string or in the request body&#8221;);  <\/p>\n<p>List&lt;Vehicle&gt; listOfVehicles = new List&lt;Vehicle&gt;();  <\/p>\n<p>Vehicle vehicle1 = new Vehicle();  <\/p>\n<p>vehicle1.Make = &#8220;Chevrolet&#8221;;  <\/p>\n<p>vehicle1.Model = &#8220;Camaro&#8221;;  <\/p>\n<p>listOfVehicles.Add(vehicle1);  <\/p>\n<p>Vehicle vehicle2 = new Vehicle();  <\/p>\n<p>vehicle2.Make = &#8220;Chevrolet&#8221;;  <\/p>\n<p>vehicle2.Model = &#8220;Tahoe&#8221;;  <\/p>\n<p>listOfVehicles.Add(vehicle2);  <\/p>\n<p>Vehicle vehicle3 = new Vehicle();  <\/p>\n<p>vehicle3.Make = &#8220;Ford&#8221;;  <\/p>\n<p>vehicle3.Model = &#8220;Mustang&#8221;;  <\/p>\n<p>listOfVehicles.Add(vehicle3);  <\/p>\n<p>var requestedVehicles = from vehicle in listOfVehicles  <\/p>\n<p>where vehicle.Make == make  <\/p>\n<p>select vehicle;  <\/p>\n<p>IEnumerable&lt;Vehicle&gt; enumerableListOfVehicles = requestedVehicles;  <\/p>\n<p>return req.CreateResponse(HttpStatusCode.OK, enumerableListOfVehicles);  <\/p>\n<p>}  <\/p>\n<p>public class Vehicle  <\/p>\n<p>{  <\/p>\n<p>public string Make { get; set; }  <\/p>\n<p>public string Model { get; set; }  <\/p>\n<p>}<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You should have something like the following:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/image617.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/image_thumb542.png\" width=\"745\" height=\"307\"><\/a><\/p>\n<p>&nbsp; <\/p>\n<h2>Step 3 \u2013 Test the Azure function in Azure\u2019s portal<\/h2>\n<p>Since the Azure Functions contain functional code, you can immediately test your new function.  <\/p>\n<p>In the Develop tab, review the Code window and notice that this C# code expects an HTTP request with a \u201cmake\u201d value (car make) passed either in the message body or in a query string. When the function runs, this value is used to filter the data to return.  <\/p>\n<p>Scroll down to the <b>Request body<\/b> text box, change the value of the <b>make<\/b> property to \u201c<b>Chevrolet<\/b>\u201d, and click <b>Run<\/b>. You will see that execution is triggered by a test HTTP request, information is written to the streaming logs, and the function response (list of filtered cars) is displayed in the Output.  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image00613.jpg\"><img decoding=\"async\" title=\"clip_image006\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image006\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image006_thumb12.jpg\" width=\"752\" height=\"207\"><\/a>  <\/p>\n<p>To trigger execution of the same function from another browser window or tab, copy the Function URL value from the Develop tab.  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0087.jpg\"><img decoding=\"async\" title=\"clip_image008\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image008\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image008_thumb7.jpg\" width=\"759\" height=\"202\"><\/a>  <\/p>\n<p>And now paste it in a browser address bar but don\u2019t forget to append an additional parameter with \u201cmake=Chevrolet\u201d or \u201cmake=Ford\u201d (query string value as <b>&amp;make=Chevrolet<\/b>) and hit enter. You\u2019ll get the same JSON data in the browser:  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0106.jpg\"><img decoding=\"async\" title=\"clip_image010\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image010\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image010_thumb6.jpg\" width=\"769\" height=\"221\"><\/a>  <\/p>\n<p>You can also test it with <a href=\"https:\/\/curl.haxx.se\/\">curl<\/a> or other tools like <a href=\"https:\/\/www.getpostman.com\/\">PostMan<\/a> like explained in <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/functions-test-a-function\/\">Testing Azure Functions<\/a>.  <\/p>\n<h2>Step 4 \u2013 Develop your Xamarin app and consume the Azure function<\/h2>\n<p>Now that our Azure Function works and is tested, let\u2019s create our Xamarin.Forms app.  <\/p>\n<p>I created a plain \u201cBlank App (Xamarin.Forms Portable)\u201d solution using the following template:  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0127.jpg\"><img decoding=\"async\" title=\"clip_image012\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image012\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image012_thumb7.jpg\" width=\"571\" height=\"399\"><\/a>  <\/p>\n<p>Once you have the solution, I usually get rid of the Windows 8.1 projects and just leave the Android, iOs and UWP projects plus the PCL project, of course, as I show below:  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0132.png\"><img decoding=\"async\" title=\"clip_image013\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image013\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image013_thumb1.png\" width=\"437\" height=\"186\"><\/a>  <\/p>\n<p>Since this is a Xamarin.Forms solution and this is a pretty straight forward sample, we\u2019ll just need to change code in the shared PCL project.  <\/p>\n<p>In particular, we just need to add code in the App.cs.  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0141.png\"><img decoding=\"async\" title=\"clip_image014\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image014\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image014_thumb1.png\" width=\"396\" height=\"260\"><\/a>  <\/p>\n<p>Next, add the <b>Newtonsoft.Json Nuget<\/b> package to your PCL project:  <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0164.jpg\"><img decoding=\"async\" title=\"clip_image016\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image016\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image016_thumb4.jpg\" width=\"545\" height=\"169\"><\/a>  <\/p>\n<p>Now, because I want to have a quick proof of concept, I wrote all the code as C# code. Of course, in a more elaborated Xamarin.Forms app, I usually would use XAML for my controls and views rather than by adding controls in C# like I\u2019m doing in this example. But for the sake of brevity, I just added C# code.  <\/p>\n<p>Within the App.cs, add the line:  <\/p>\n<p>using Newtonsoft.Json;  <\/p>\n<p>And now paste the following code in your <b>App.cs<\/b> file within your app namespace definition:<\/p>\n<p>&nbsp;<\/p>\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"623\">\n<p>public class App : Application  <\/p>\n<p>{  <\/p>\n<p>static ListView lstVehicles = new ListView();  <\/p>\n<p>static Label titleLabel = new Label();  <\/p>\n<p>public App()  <\/p>\n<p>{  <\/p>\n<p>MainPage = GetMainPage();  <\/p>\n<p>}  <\/p>\n<p>public static ContentPage GetMainPage()  <\/p>\n<p>{  <\/p>\n<p>titleLabel.HorizontalTextAlignment = TextAlignment.Center;  <\/p>\n<p>titleLabel.Text = &#8220;Testing Azure Functions from Xamarin!&#8221;;  <\/p>\n<p>Button newButn = new Button()  <\/p>\n<p>{  <\/p>\n<p>Text = &#8220;Connect to Azure Function&#8221;,  <\/p>\n<p>};  <\/p>\n<p>newButn.Clicked += newButn_Clicked;  <\/p>\n<p>lstVehicles.ItemTemplate = new DataTemplate(typeof(TextCell));  <\/p>\n<p>lstVehicles.ItemTemplate.SetBinding(TextCell.TextProperty, &#8220;Model&#8221;);  <\/p>\n<p>return new ContentPage  <\/p>\n<p>{  <\/p>\n<p>Content = new StackLayout()  <\/p>\n<p>{  <\/p>\n<p>Children = {  <\/p>\n<p>titleLabel,  <\/p>\n<p>newButn,  <\/p>\n<p>lstVehicles  <\/p>\n<p>}  <\/p>\n<p>}  <\/p>\n<p>};  <\/p>\n<p>}  <\/p>\n<p>static async void newButn_Clicked(object sender, EventArgs e)  <\/p>\n<p>{  <\/p>\n<p>string previousTextValue = titleLabel.Text;  <\/p>\n<p>titleLabel.Text = &#8220;******* Executing the Azure Function! ********&#8221;;  <\/p>\n<p>VehiclesAzureFunction vehiclesAzureFunction = new VehiclesAzureFunction(&#8220;https:\/\/helloworldfunctcdltll.azurewebsites.net\/&#8221;);  <\/p>\n<p>\/\/Consume the Azure Function with hardcoded method easier to see as an example  <\/p>\n<p>var vehiclesList = await vehiclesAzureFunction.GetVehiclesHardCodedAsync();  <\/p>\n<p>\/\/Consume the Azure Function with HttpClient reusable code within the Function\/Service Agent  <\/p>\n<p>\/\/var vehiclesList = await vehiclesAzureFunction.GetVehiclesAsync(&#8220;Chevrolet&#8221;);  <\/p>\n<p>lstVehicles.ItemsSource = vehiclesList;  <\/p>\n<p>titleLabel.Text = previousTextValue;  <\/p>\n<p>}  <\/p>\n<p>}  <\/p>\n<p>public class Vehicle  <\/p>\n<p>{  <\/p>\n<p>public string Make { get; set; }  <\/p>\n<p>public string Model { get; set; }  <\/p>\n<p>}  <\/p>\n<p>public class VehiclesAzureFunction  <\/p>\n<p>{  <\/p>\n<p>public VehiclesAzureFunction()  <\/p>\n<p>{  <\/p>\n<p>}  <\/p>\n<p>public async Task&lt;List&lt;Vehicle&gt;&gt; GetVehiclesHardCodedAsync()  <\/p>\n<p>{  <\/p>\n<p>var client = new System.Net.Http.HttpClient();  <\/p>\n<p>string url = $&#8221;https:\/\/helloworldfunctcdltll.azurewebsites.net\/api\/HttpTriggerVehicleList?code=mi11r1elo9fwd2cafw5ozctgy8yug8fr0cjc&amp;make=Chevrolet&#8221;;  <\/p>\n<p>var response = await client.GetAsync(url);  <\/p>\n<p>var vehiclesJson = response.Content.ReadAsStringAsync().Result;  <\/p>\n<p>List&lt;Vehicle&gt; listOfVehicles = JsonConvert.DeserializeObject&lt;List&lt;Vehicle&gt;&gt;(vehiclesJson);  <\/p>\n<p>return listOfVehicles;  <\/p>\n<p>}  <\/p>\n<p>}<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Basically, I\u2019m using the System.Net.Http.HttpClient class in order to call the Azure Function, in the same way you do when consuming regular Web API services. That code is implemented in a Function\/Service agent class called VehiclesAzureFunction, and I\u2019m running that code when the user presses the \u201cConnect to Azure Function\u201d.  <\/p>\n<p>When running the Xamarin app in the Android emulator, this is what you get when starting the app and after pressing the button and calling the Azure Function:  <\/p>\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"312\">\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0184.jpg\"><img decoding=\"async\" title=\"clip_image018\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image018\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image018_thumb4.jpg\" width=\"296\" height=\"564\"><\/a><\/p>\n<\/td>\n<td valign=\"top\" width=\"312\">\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image0204.jpg\"><img decoding=\"async\" title=\"clip_image020\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"clip_image020\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/clip_image020_thumb4.jpg\" width=\"293\" height=\"563\"><\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Code available at GitHub<\/h2>\n<p>You can grab all the code from GitHub, as it\u2019ll easier to see than just copying\/pasting from a blog post. In the code at GitHub I\u2019m also using some base classes with generics that are useful when you want to re-use more code in a Xamarin project.  <\/p>\n<p><b>Code download in GitHub<\/b>: <a href=\"https:\/\/github.com\/CESARDELATORRE\/Xamarin_AzureFunctions_PoC\">https:\/\/github.com\/CESARDELATORRE\/Xamarin_AzureFunctions_PoC<\/a>  <\/p>\n<h2>Next steps<\/h2>\n<p>In this blog post I simply created an <b>Azure Function<\/b> that was directly called through HTTP from a <b>Xamarin.Forms<\/b> app and I\u2019m showing in the mobile app the returned data. <\/p>\n<p>Once you have deployed you Azure Function you can learn on <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/functions-scale\/\">How to scale Azure Functions<\/a>, as well.&nbsp; <\/p>\n<p>But, there are many other possibilities you can do with Azure Functions like cool things related to events, for instance, triggering an Azure Function when a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Webhook\"><strong>WebHook<\/strong><\/a> event is received (like a <a href=\"https:\/\/developer.github.com\/webhooks\/\"><strong>GitHub WebHook<\/strong><\/a> or a custom <a href=\"https:\/\/docs.asp.net\/projects\/webhooks\/en\/latest\/overview.html\"><strong>ASP.NET WebHook<\/strong><\/a>) like in this example: <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/functions-create-a-web-hook-or-api-function\/\"><strong>Azure Function triggered by a WebHook<\/strong><\/a>.  <\/p>\n<p>Another interesting scenario would be to create an Azure Function that receives a WebHook and that <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/functions-triggers-bindings\/#azure-notification-hub-output-binding\"><strong>Azure Function generates a Mobile Push Notification<\/strong><\/a> to be sent to mobile devices (iOS, Android and Windows devices) through Azure Push Notifications Hub.  <\/p>\n<p>I also like this Azure Function example using the new <strong>Azure Cognitive Services<\/strong> (in this case, purely server-side related): <a href=\"https:\/\/blogs.msdn.microsoft.com\/martinkearn\/2016\/05\/06\/smart-image-re-sizing-with-azure-functions-and-cognitive-services\/\">Smart image re-sizing with Azure Functions and Cognitive Services<\/a>.  <\/p>\n<p>At the end of the day, Azure Functions can be useful when testing small proof of concepts of code or quick actions with C# or Node.js code and you don\u2019t want\/need to deploy a whole VS project. You could use it even for building simple microservices, too. Although, for a more complex\/large Microservices approach solution, you should check out this MSDN Magazine article <strong><a href=\"https:\/\/msdn.microsoft.com\/en-us\/magazine\/mt595752.aspx\">Azure Service Fabric and the Microservices Architecture<\/a><\/strong> that I wrote. \ud83d\ude42  <\/p>\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was testing Azure Functions by creating a simple proof of concept with a Xamarin.Forms client and since there\u2019s not much info about \u201cusing Azure Functions from Xamarin\u201d I thought it was a good idea to publish this Getting Started or Walkthrough in my MSDN blog. Make no mistake about it, you consume an Azure [&hellip;]<\/p>\n","protected":false},"author":362,"featured_media":12806,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[28,124],"class_list":["post-4195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cesardelatorre","tag-azure-functions","tag-xamarin"],"acf":[],"blog_post_summary":"<p>I was testing Azure Functions by creating a simple proof of concept with a Xamarin.Forms client and since there\u2019s not much info about \u201cusing Azure Functions from Xamarin\u201d I thought it was a good idea to publish this Getting Started or Walkthrough in my MSDN blog. Make no mistake about it, you consume an Azure [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/4195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/comments?post=4195"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/4195\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media\/12806"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media?parent=4195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/categories?post=4195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/tags?post=4195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}