So, Let’s create an Azure project that will send the data from the Service Bus to the Logic App.
Firstly, let’s know what is Service Bus, Function App, Logic App:
- Service Bus: Azure Service Bus is like a post office in the cloud where your applications can send and receive messages reliably, allowing them to communicate with each other even if they’re not running at the same time
- Function App : A Function app in Azure is like a toolbox where you can store and run small pieces of code (functions) without worrying about managing the infrastructure.
- Logic App: Azure Logic Apps is a leading integration platform as a service (iPaaS) built on a containerized runtime. Deploy and run Logic Apps anywhere to increase scale and portability while automating business-critical workflows anywhere
Step 1: We have to create a Logic app in our Azure portal. Below I have created a Standard Logic App. And after creating the Logic app we have to create a Workflow where we will be designing our Workflow.
Step 2: Now we have to create Service Bus from where we will be sending the data. First create a “Namespace” and Then create a “Queue” name.
Step 3: Now after successfully creating the Service Bus, we have to create a Function App through which our data will Pass from the Service Bus to the Logic App.
Note: While giving the Service Bus Connection name we have to click on “New” and then it will give you the namespace that you created earlier. Then give put your queue name accordingly.
Step 4: Now let’s go back to our Logic App which we created and we have to design our Logic App. So here I have designed my logic app which will give me Employee Details in the JSON Format.
Note : It’s up to you to design your own logic app for example : Here you can also use CosmosDB or Blob storage to further store your Data or You can also send an email of Employee Details to someone
Step 5: Now let’s come to the function app and write the below code which will help to send the data from the service bus to the logic app.
Below is the C# code:
using System;
using System.Threading.Tasks;
using System.Net.Http;
using System.Text;
// Set up the URI for the logic app workflow. You can also get this value on the logic app's 'Overview' pane, under the trigger history, or from an environment variable.
private static string logicAppUri = @"Your-Workflow-URL";
private static HttpClient httpClient = new HttpClient();
public static async Task Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
var response = await httpClient.PostAsync(logicAppUri, new StringContent(myQueueItem, Encoding.UTF8, "application/json"));
}
Step 6: Now from the Service Bus let’s trigger the message and send the data by clicking on “send messages”.
Step 7: Come to your Logic App and check the transaction accordingly. Like, here we can see successfully received the data from Service Bus.
Thanks for stopping by! Your visit means a lot. Please Follow me😊 Stay tuned for more content. Exciting stuff coming your way soon! 🚀 #StayTuned. Also, visit on RioTech.
Comments
Post a Comment