Thursday, 29 November 2018

Create .NET Core Azure Function with Visual Studio 2017

Introduction

With all the talk about Serverless and Azure Functions, it’s a good time to learn how to do this if you don’t already know. In this post, we’ll do a walkthrough of you to create a simple .NET Core 2.1 Azure Function with Visual Studio 2017.

Prerequisites

First of all, let’s set up our environment.

1) Install Visual Studio 2017 (you can download the Visual Studio Community Edition for free here).

2) Install the .NET desktop development workload for Visual Studio. I have these options enabled:

image

image

3) Install the Universal Windows Platform development workload:

image

4) Install the ASP.NET and web development workload:

image

image

5) Install the Azure development workload:

image

image

6) Install the .NET Core cross-platform development

image

image

7) Install the Azure Functions Core Tools:

You can find more info here.

8) Install PostMan. This is a free tool for making HTTP requests so it’s great for testing out APIs. You can download it here.

Create a new Function App V2 project with Visual Studio 2017:

1) Create a new project in Visual Studio (File > New > Project)

image

2) Select Cloud > Azure Functions then select a folder and click OK.

image

3) On the new window that pops up, make sure you click the drop down and select Azure Functions v2 (.NET Core) and Http Trigger.

image

Click OK when done.

4) Let’s add some code. Rename Function1.cs to HttpTrigger.cs and add the contents below.

This method simply takes an HttpRequest input, extracts the two strings FirstName and LastName and outputs a greeting message.

Debug your Azure Function in Visual Studio

1) At the time of writing, there’s an issue with Visual Studio debugging for .NET Core Azure Functions V2. The workaround for this is here. Go ahead and go through this article then come back to continue at step 2.

2) Hit F5 to start debugging your function and you should be presented with something like this

image

As we can see, our function is running and the HttpTrigger is listed in green.

3) Let’s open up PostMan, create a new Request. It prompts you to create a request name and category.

image

image

4) Change the request to POST

image

5) Go to Body, select raw and add the JSON content below

image

6) In the console window, copy the HttpTrigger URL into PostMan:

image

image

7) Click Send in PostMan

You should get the greeting message below in PostMan

image

And you should see a request come through in the Azure Function console window

image

So, there you have it. Your first Azure Function running .NET Core 2.1. Hit Shift+F5 to stop debugging. You can find the project code on GitHub here.

35 comments:

  1. Great Article. Thank you for sharing! Really an awesome post for every one.

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

    ReplyDelete
  2. Wow! this is Amazing! Do you know your hidden name meaning ? Click here to find your hidden name meaning

    ReplyDelete
  3. This is what I was wondering for! Nice information. Keep it up
    Germany VPS Server

    ReplyDelete
  4. Nicely you explained everything in your article. Thanks for your information, this is nice and helpful… Definitely going to share this article to my friends.
    Linux VPS Hosting

    ReplyDelete
  5. Wohh I love it, I mean this blog is just awesome. I personally love this informative article… Keep posting such information… Keep Going!
    Germany VPS Hosting

    ReplyDelete
  6. Wohh I love it, I mean this blog is just awesome. I personally love this informative article… Keep posting such information… Keep Going!
    Germany VPS Hosting

    ReplyDelete
  7. This concept is a good way to enhance the knowledge.thanks for sharing..
    DevOps Training
    DevOps Online Training

    ReplyDelete
  8. Hi I am from Join Pak Navy I and I really like your work thanks for this information and keep it up you are doing good

    ReplyDelete
  9. Welcome to Advance Case Search at Sindh High Court. You can easily learn how to check case status on Case Search portal of Sindh High Court.

    ReplyDelete
  10. Appslure is an award-winning mobile app development agency building feature-packed and interactive mobile applications for startups, medium and large enterprises.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Bring your HP Envy printer disconnected to online with simple investigating steps. we prescribe you to follow these means to fix hp envy 5530 offline windows 10.

    ReplyDelete
  14. Nice Blog
    Your blog is very instructive for IT people like me. Keep sharing this type of blog it really helps us. Web Hosting plays a very important role in the business world. And it is important to have the best hosting services. Buy the best USA VPS Hosting service for your website.

    ReplyDelete
  15. Very useful knowledge you are sharing for IT sector peoples. Keep writing this type of blogs because it is helpful for us. Thanks for Sharing.
    Grab securable USA VPS Hosting, if you want to grow your online business. Having a VPS Server in USA is most reliable & securable.

    ReplyDelete
  16. Thanks for sharing technical related information The information given in this blog is very useful thanks to which if you want to know something about server hosting then see what you should know aboutUSA VPS Hosting and how it can be important for this modern world. Thanks once again.


    ReplyDelete
  17. Really I'm very happy to find such a great post today. People are always looking for informative and creative ideas on the internet and I think you have covered both in this post. kissanime.ac website

    ReplyDelete
  18. I found this one pretty fascinating and it should go into my collection. Very good work! I am Impressed. We appreciate that please keep going to write more content. giftalworld app

    ReplyDelete
  19. This amazing content is exactly what I was looking for, thanks for sharing keep up the good work. Also, Check auction sites like eBay

    ReplyDelete
  20. What a great content we have here buy painkillers online as we browse we also see this blog too and is pretty good buy norco online we also realize that blog are good for business we also bring buy oxycodone online best blog to visit

    ReplyDelete