Azure Functions C#

This article will discuss creating Azure Functions in C# using Azure Portal.

Azure Functions C#

Before Starting the Azure Functions in C#, Assuming, you have some idea on Azure Function. Follow the below steps.

1. Log in to the  Azure Portal (https://portal.azure.com/)

2. Once you log in to the Portal, search for the Function App and then click on the Search result.

azure functions examples c#

3. Now, On the Function App window, click on the + Add button to create the new function App.

azure function example c#

4. On the Create Function App window, Provide the below Details.

On the Basics Tab, you will have to provide the below details

  • Subscription: Select your Azure Subscription.
  • Resource Group: You can choose your existing Resource Group, or If you do not have a Resource Group, you can create a new Resource Group by clicking on the Create new link.
  • Function App name: Provide a unique name for your Azure Function App.
  • Publish: Choose the Code option for this.
  • Runtime stack: Choose the .NET Core for this option.
  • Version: Choose version 3.1.
  • Region: Choose the Region for your Azure Function App.

Now, click on the Next: Hosting > button to go to the Hosting tab.

azure function c#

5. Now, on the Hosting tab, provide the below details

  • Storage account: Choose your existing Storage Account, or you can create a new one by clicking the Create new button.
  • Operating System: Choose Windows as your Operating System.
  • Plan Type: You can choose the Plan type based on your Subscription.

Now click the Next: Monitoring > button to navigate to the Monitoring tab.

c# azure function

6. On the Monitoring tab, Provide the below details

  • Enable Application Insights: You can select the Yes option here.
  • Application Insights: Choose application Insights. The Region of the Application insight should be the same as the Storage account.

Then click on the Review + Create button

c# azure functions

7. Finally, click on the Create Button to create the Azure Function App.

Now, you can see, the Azure Function App is deployed successfully without any issues.

azure function app tutorial c#

Now click the Go to Resource button to navigate to the Azure Function App we created. So now our Function App is ready so the next step is to create the Function. You can create that in two ways

Click on the Functions link from the left side on the Function App page and then click on the + Add button (Modern Experience)

How to create azure function in azure portal

Another way is to click on the Switch to classic experience —> Continue to the classic experience

create azure function from azure portal

Now click on the + Add New Function button

How to create azure function C# from azure portal

Now, if we will consider the first option (Modern Experience)

Once you click on the + Add button, Click on the HTTP trigger. You can select the type of trigger based on your business need.

How to Create a function using Azure Portal

On the New Function window, You need to provide the Function name and Authorization level as Function. But can choose Anonymous or Admin based on your requirement. Then click on the Create Function button to create the Azure Function.

How to create Azure Functions using Azure Portal

Now you can see the function was created Successfully without any issues.

logging in azure functions c#

Now, if you want to check whether the Azure function is working properly or not, You can click on the Code + Test link from the left-side navigation. If you want to modify or add any code, you can do that on the Editor and then run it to check if the function works.

azure function example c#

Now, choose the HTTP method and provide the name parameter value in the body in JSON format, as mentioned below, and then click on the Run button to execute the function.

Create your first function in the Azure portal

Now see here the function executed successfully with the expected output and proper response code, i.e. 200 OK.

One more thing: If you want to check whether this function is working using the Postman app, you can click on the Get function URL button from the top. It will provide you with the function URL.

Create your first Azure function in the Azure portal

Now click on the Copy button from the below window to copy the Azure Function URL.

You will get the URL below

Create your first Azure function using the Azure portal

Now, Open the Postman app, Select the HTTP method, paste the Azure Function URL, Provide the name parameter value in JSON format in the body, and click the Send button. You can see it. You provided us the expected output with the Proper response code 200 OK.

Azure Function Using C#

Wrapping Up

This article discussed how to create Azure Functions in C# using Azure Portal. Thanks for reading this article !!!