Please enable Javascript for better experience...
Getting started with Function App in Azure Portal - Azure function service bus topic trigger
By Rahul Kumar Jha | Jul 7, 2020 | In Articles | Update: Aug 5, 2020 | Total Views [ 4068 ]
Taged In
(2 Like)
Rate

In this article, I will demonstrate azure function app where I will show creating service bus trigger inside function app.

Introduction

In this article, I will demonstrate azure function app where I will show creating service bus trigger inside function app. Before we start, please create a service bus topic and add at least one subscription to it. Follow below link to create topic and subscription.

Click here to configure service bus topic

Steps to configure Function app in Azure portal

After you created prerequisites for next step, follow below steps to continue. To create azure function app and fetched message from service bus first steps would be to create a function app.

Open Azure portal (portal.azure.com), Go to resource, type “function app”, you can also click on Compute section and there you will find Function App option

01

Enter details and press “Review + Create” button. This will take some time to build. You will be asked to choose a platform. I have chosen .Net Core so my function app will run on .Net Core.

02

It will take some time to deploy your resource. Once deployment is completed, you can navigate to see the overview of the function. Now go to “Function” tab in left pane, you will find an option to add function. You will see various types of functions you can create. Select “Service bus topic trigger”.

03

Enter basic details like connection, topic name and subscription name. Press “Create Function” button when done.

04

You can edit your function as well and can change topic and subscription names as per your choice.

05

Now go to your function. Here you will see few options in left pane like “Code + Test” where you can test your function and “Integration” which shows structure or connectivity of your function. In below screenshot you can see that there is a trigger associated with your function and there is an option to add input and output.

06

You can also enable disable your function. For that, just click on your function app and click on function tab on left pane. Here you will find your function. Select the function and click on “Enable” to enable or “Disable” to disable your function.

07

In this article, we are demonstrating trigger execution when we add any message to topic. To do so, open trigger and select “Code + Test” option. Enable logs. Here you will see C# code and “function.json” configuration file which contains configuration related to the trigger.

08

Now open service bus topic “userservicebustopic”, go to “Service Bus Explorer” and add a message of any type from available options. You can send simple text message or message in XML or JSON format. Choose any. I am sending simple text message for demo purpose.

09

Go to service bus trigger and wait for a second. You should logs stating that trigger has been executed.

10

As soon as you see this log, message has been dequeue from service bus topic. Default lock is PeekLock that send “Complete message” acknowledgement if message is successfully received or send “Abandon” status or “Retry” if encounters an error. You can set retry policy to tell your service bus trigger function that how many time trigger should try to retrieve message from queue if message get failed. After said number of try (default is 5 times), a message is parked in DeadLetter queue which is further set to take care.

Hope this helps you.

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer dotnet-concept.com

Public profile: user/profile/99900001


Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
 
 
 
 
 
Sponsors