How to create an Azure Function in Visual Studio
I have relocated this article to its new home here: https://benperk.github.io/msdn/2018/2018-04-how-to-create-an-azure-function-in-visual-studio.html
These are some good instructions as well “Create your first function using Visual Studio”. But I like to try it out myself. Check out these other articles as well.
- How to connect to a database from an Azure Function
- Deploy an Azure Function created from Visual Studio
- Check out all my Azure Function articles here
First, open Visual Studio and create the Azure Function, similar to that shown in Figure 1.
Figure 1, how to create an Azure Function using Visual Studio
Select the trigger type, I chose the below configuration, I.e. Http Trigger as seen in Figure 2.
Figure 2, how to create an Azure Function using Visual Studio
Without making any changes, I pressed F5 and was then asked to install the Azure Functions CLI tools, Figure 3 and I did that.
Figure 3, how to create an Azure Function using Visual Studio
The simulator started up, as seen in Figure 4.
Figure 4, how to create an Azure Function using Visual Studio
Once the CLI tools were installed, the CMD window, seen in Figure 5 opened up and provided me the URL to test the Azure Function.
Figure 5, how to test local an Azure Function using Visual Studio
Then I used CURL from another CMD window to call and test the Azure Function, see Figure 6.
Figure 6, how to test local an Azure Function using Visual Studio
That was too easy, Azure Functions are pretty cool.
Be sure to check out my other Azure Function articles here.
After I published my Function, I had some problems:
I resolved them, but the thing is that when I access the Function in the portal I have limited means of updating there in the portal itself. This if fine, since I decided to create from Visual Studio, I will need to develop, test and publish in Visual Studio from this point on. Do not think that you can go back and forth between developing in the portal and in Visual Studio. It is either or and you need to decide how you want to develop. When created from this direction, I see this, Figure 7 in the portal when I navigate to it.
Figure 7, how to test local an Azure Function using Visual Studio, azure portal
You can consider creating the Azure Function App and Function, then downloading the project and doing some developing and testing in Visual Studio, then cut & paste the changes from Visual Studio into the Azure Function IDE in the portal.