{"id":1014,"date":"2023-07-04T05:30:52","date_gmt":"2023-07-04T05:30:52","guid":{"rendered":"https:\/\/fredborg.org\/?p=1014"},"modified":"2023-07-04T05:30:53","modified_gmt":"2023-07-04T05:30:53","slug":"using-azure-service-bus-with-business-central","status":"publish","type":"post","link":"https:\/\/fredborg.org\/?p=1014","title":{"rendered":"Using Azure Service Bus with Business Central"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Integrating different systems with your Business Central is the best way to be able to get the most out of your IT platform, however, once you have a certain amount of integration it can become challenging to maintain, because while Business Central does have the ability to be customized so that it fits our every need, you will very fast run into the question, whether or not all of this functionality and responsibility should be placed inside your ERP system, and once you ask yourself that question you already know the answer, which is no. One of the main problems that we face when creating integrations is what should happen if we try to send our data but the service that we are trying to reach is down or for some reason does not accept the request at the time when you are trying to send data to it, what should you then do? Let it fail? or try again? and if you choose to try again, how many times should you try? This is where the Azure Service Bus comes into play.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Azure Service Bus<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Azure Service Bus has two main functionalities, the first and most used is the message queue. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"255\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/image-17.png\" alt=\"\" class=\"wp-image-1018\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/image-17.png 736w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/image-17-300x104.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The concept behind the message queue is that the sender will send their requests to Azure Service Bus which will then send them to a receiver, and if the receiver for some reason cannot receive the message, then the message will be queued until it is ready, or if the receiver returns an error the message the service bus will then be able to retry, or it can place the message in a dead letter queue, which someone of something can monitor, the idea is to remove the tight coupling between the sender and the receiver, this also means that if your systems require a tight coupling then a service bus is not the right solution for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The second feature of an Azure service bus is the concept of topics, this is where your messages will be put into different queues depending on a topic that you choose in your message, from the sender side everything will work in much the same way apart from the fact that you must add a topic to your message, however on the receiver side things work a little different because when using topics then the receiver must subscribe to a given topic, and when a message is created on the queue with a topic that the receiver has subscribed to, then the receiver will receive that message, the main difference between using topics is that a simple Message queue is a one to one relationship where you have one queue and one receiver, while if you use topics it becomes a one to many relationships because you can have multiple receivers that subscribe to the same topic.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"449\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/image-19.png\" alt=\"\" class=\"wp-image-1022\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/image-19.png 665w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/image-19-300x203.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Setting up an Azure Service Bus<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To set up an Azure service bus, you must go to your<a href=\"https:\/\/portal.azure.com\/\" target=\"_blank\" rel=\"noreferrer noopener\"> Azure portal<\/a> and search for service bus.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"201\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image.png\" alt=\"\" class=\"wp-image-1027\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Press Create<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"196\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-1.png\" alt=\"\" class=\"wp-image-1028\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And fill in the information (Basic does not give access to Topics):<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"469\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-2.png\" alt=\"\" class=\"wp-image-1029\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-2.png 766w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-2-300x184.png 300w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once your resource has been created, head to Queues and create a new Queue.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"467\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-3-1024x467.png\" alt=\"\" class=\"wp-image-1031\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-3-1024x467.png 1024w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-3-300x137.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-3-768x350.png 768w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-3.png 1338w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I am going to leave everything as default, but this is where you are able to control how your queue should work, including if you wish to enable dead lettering, which I would suggest that you do when setting this up in a production environment. Next, we need to head over to our development environment. I will be using Visual Studio and C#, and I will also be using Azure Functions to interact with my queue. If you do not have Visual Studio you can download the free community edition <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/community\/\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> I will be using a Http triggered Azure function in this example.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"898\" height=\"215\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-4.png\" alt=\"\" class=\"wp-image-1034\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-4.png 898w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-4-300x72.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-4-768x184.png 768w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"642\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-5.png\" alt=\"\" class=\"wp-image-1035\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-5.png 989w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-5-300x195.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-5-768x499.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we will need to install a nugget package called Azure.Messaging.ServiceBus<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"520\" height=\"265\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-6.png\" alt=\"\" class=\"wp-image-1036\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-6.png 520w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-6-300x153.png 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We will now need a connection string to our Service Bus, so head back to your Azure portal and head to Shared access policies click on the RootManageSharedAccessKey and copy the value from the Primary Connection String.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"324\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-7-1024x324.png\" alt=\"\" class=\"wp-image-1037\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-7-1024x324.png 1024w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-7-300x95.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-7-768x243.png 768w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-7.png 1338w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Head back to Visual Studio and open the local.settings.json and add your connection string:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n{\n    &quot;IsEncrypted&quot;: false,\n  &quot;Values&quot;: {\n    &quot;AzureWebJobsStorage&quot;: &quot;UseDevelopmentStorage=true&quot;,\n    &quot;FUNCTIONS_WORKER_RUNTIME&quot;: &quot;dotnet&quot;,\n    &quot;ServiceBusConnectionstring&quot;: &quot;Endpoint=sb:\/\/fredborgdemoservicebus.servicebus.windows.net\/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey={KEY}&quot;\n  }\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Next change your function code to look as follows:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.IO;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Extensions.Http;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Logging;\nusing Newtonsoft.Json;\nusing Azure.Messaging.ServiceBus;\n\nnamespace SendMessageToServiceBus\n{\n    public static class Function1\n    {\n        &#x5B;FunctionName(nameof(SendMessage))]\n        public static async Task&lt;IActionResult&gt; SendMessage(\n            &#x5B;HttpTrigger(AuthorizationLevel.Function, &quot;get&quot;, &quot;post&quot;, Route = null)] HttpRequest req,\n            ILogger log)\n        {\n\n            string name = req.Query&#x5B;&quot;name&quot;];\n            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();\n            dynamic data = JsonConvert.DeserializeObject(requestBody);\n            name = name ?? data?.name;\n            \n            string connectionstring = Environment.GetEnvironmentVariable(&quot;ServiceBusConnectionstring&quot;);\n\n            ServiceBusClient serviceBusClient = new ServiceBusClient(connectionstring);\n\n            var sender = serviceBusClient.CreateSender(&quot;demo&quot;);\n\n            ServiceBusMessage message = new ServiceBusMessage(requestBody);\n\n            await sender.SendMessageAsync(message);\n\n            string responseMessage = string.IsNullOrEmpty(name)\n                ? &quot;This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.&quot;\n                : $&quot;Hello, {name}. This HTTP triggered function executed successfully.&quot;;\n\n            return new OkObjectResult(responseMessage);\n        }\n    }\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Where the line <strong>var sender = serviceBusClient.CreateSender(&#8220;demo&#8221;) <\/strong>tells the function which queue it should send its request to, and the <strong>string connection string = Environment.GetEnvironmentVariable(&#8220;ServiceBusConnectionstring&#8221;); <\/strong>gets our connection string from the local.settings.json file. If you now try to run your function, take your URL and call it from your REST program of choice, my URL looks as follows:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nPOST: http:\/\/localhost:7054\/api\/SendMessage\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">with payload:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n{\n  &quot;name&quot;: &quot;This is a message&quot;\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">This will add a new message to your job queue in your service bus in the Azure portal.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"495\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-8-1024x495.png\" alt=\"\" class=\"wp-image-1039\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-8-1024x495.png 1024w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-8-300x145.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-8-768x371.png 768w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-8.png 1144w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And if you call it again a new message will be added, next we need to add a receiver, in my case I will again use an Azure function. When creating your Azure Function you can choose the trigger type Service Bus Queue trigger which will let you set up your Connection String and Queue Name.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"441\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-9.png\" alt=\"\" class=\"wp-image-1041\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-9.png 614w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-9-300x215.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This will create a function that logs our messages I have changed my code to the following:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Host;\nusing Microsoft.Extensions.Logging;\n\nnamespace Receiver\n{\n    public class Function1\n    {\n        &#x5B;FunctionName(nameof(Run))]\n        public void Run(&#x5B;ServiceBusTrigger(&quot;demo&quot;, Connection = &quot;ServiceBusConnectionstring&quot;)]string myQueueItem, ILogger log)\n        {\n            log.LogInformation($&quot;C# ServiceBus queue trigger function processed message: {myQueueItem}&quot;);\n        }\n    }\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">When I run this function it will receive any messages that we have in our queue.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"436\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-12.png\" alt=\"\" class=\"wp-image-1044\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-12.png 989w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-12-300x132.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-12-768x339.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And if we look in our Azure Portal the message count is now 0.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"198\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-11.png\" alt=\"\" class=\"wp-image-1043\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-11.png 764w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-11-300x78.png 300w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Using Topics you need to create a Topic in Azure Portal<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"373\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-13-1024x373.png\" alt=\"\" class=\"wp-image-1046\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-13-1024x373.png 1024w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-13-300x109.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-13-768x280.png 768w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-13-1536x559.png 1536w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-13.png 1887w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The code for sending messages to a topic is the same, the only difference is that you pass your topic name instead of the queue name<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nvar sender = serviceBusClient.CreateSender(&quot;demotopic&quot;);\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">You also need to create a subscription, to do this click on your topic and choose subscription:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"280\" height=\"231\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-14.png\" alt=\"\" class=\"wp-image-1047\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"677\" height=\"507\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-15.png\" alt=\"\" class=\"wp-image-1048\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-15.png 677w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-15-300x225.png 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"323\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-16.png\" alt=\"\" class=\"wp-image-1049\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-16.png 610w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-16-300x159.png 300w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To receive a receiver create an Azure function with the trigger Service Bus Topic trigger<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"500\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-17.png\" alt=\"\" class=\"wp-image-1050\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-17.png 604w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-17-300x248.png 300w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And the code is very similar to our Message queue except it takes our subscription and topic.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing Microsoft.Azure.WebJobs;\nusing Microsoft.Azure.WebJobs.Host;\nusing Microsoft.Extensions.Logging;\n\nnamespace TopicReciever\n{\n    public class TopicReceive\n    {\n        \n        &#x5B;FunctionName(nameof(Run))]\n        public void Run(&#x5B;ServiceBusTrigger(&quot;demotopic&quot;, &quot;DemoSub&quot;, Connection = &quot;ServiceBusConnectionstring&quot;)] string mySbMsg, ILogger log)\n        {\n            log.LogInformation($&quot;C# ServiceBus topic trigger function processed message: {mySbMsg}&quot;);\n        }\n    }\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">So if I send a message to our Topic then my subscription will say that it has one message count:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"198\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-18.png\" alt=\"\" class=\"wp-image-1051\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-18.png 665w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-18-300x89.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And then when I run my Topic Receiver that message will be read<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"217\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-19.png\" alt=\"\" class=\"wp-image-1052\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-19.png 875w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-19-300x74.png 300w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-19-768x190.png 768w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If I add another subscription and send a new message while only listing to DemoSub, you will see that I only read the messages for my subscription, leaving the message in the other subscription until they are ready to receive messages.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"260\" src=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-20.png\" alt=\"\" class=\"wp-image-1053\" srcset=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-20.png 710w, https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/image-20-300x110.png 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And that is how Azure Service Bus works, this, of course, was a very simple example, but when used correctly then this can make many of our integration more flexible, I have decided not to write any AL code in this blog post because the code is the same as any other code we would write to call an HTTP triggers Azure Function so that was it for this post until next time stay safe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Integrating different systems with your Business Central is the best way to be able to get the most out of&#8230; <a class=\"read-more\" href=\"https:\/\/fredborg.org\/?p=1014\" rel=\"nofollow\"> Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":1058,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,5],"tags":[],"class_list":["post-1014","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-business-central","shapla-grid-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Azure Service Bus with Business Central - Fredborg<\/title>\n<meta name=\"description\" content=\"integration between different systems with Business Central and how Azure Service Bus can help with this\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fredborg.org\/?p=1014\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Azure Service Bus with Business Central - Fredborg\" \/>\n<meta property=\"og:description\" content=\"integration between different systems with Business Central and how Azure Service Bus can help with this\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fredborg.org\/?p=1014\" \/>\n<meta property=\"og:site_name\" content=\"Fredborg\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-04T05:30:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-04T05:30:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus-1024x576.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"576\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dfredborg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dfredborg\" \/>\n<meta name=\"twitter:site\" content=\"@dfredborg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dfredborg\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fredborg.org\/?p=1014#article\",\"isPartOf\":{\"@id\":\"https:\/\/fredborg.org\/?p=1014\"},\"author\":{\"name\":\"dfredborg\",\"@id\":\"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d\"},\"headline\":\"Using Azure Service Bus with Business Central\",\"datePublished\":\"2023-07-04T05:30:52+00:00\",\"dateModified\":\"2023-07-04T05:30:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fredborg.org\/?p=1014\"},\"wordCount\":1134,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d\"},\"image\":{\"@id\":\"https:\/\/fredborg.org\/?p=1014#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png\",\"articleSection\":[\"Azure\",\"Business Central\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fredborg.org\/?p=1014#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fredborg.org\/?p=1014\",\"url\":\"https:\/\/fredborg.org\/?p=1014\",\"name\":\"Using Azure Service Bus with Business Central - Fredborg\",\"isPartOf\":{\"@id\":\"https:\/\/fredborg.org\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fredborg.org\/?p=1014#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fredborg.org\/?p=1014#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png\",\"datePublished\":\"2023-07-04T05:30:52+00:00\",\"dateModified\":\"2023-07-04T05:30:53+00:00\",\"description\":\"integration between different systems with Business Central and how Azure Service Bus can help with this\",\"breadcrumb\":{\"@id\":\"https:\/\/fredborg.org\/?p=1014#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fredborg.org\/?p=1014\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fredborg.org\/?p=1014#primaryimage\",\"url\":\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png\",\"contentUrl\":\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png\",\"width\":2560,\"height\":1440},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fredborg.org\/?p=1014#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fredborg.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Azure Service Bus with Business Central\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fredborg.org\/#website\",\"url\":\"https:\/\/fredborg.org\/\",\"name\":\"Fredborg\",\"description\":\"Business Central and Azure\",\"publisher\":{\"@id\":\"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fredborg.org\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d\",\"name\":\"dfredborg\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fredborg.org\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/download.png\",\"contentUrl\":\"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/download.png\",\"width\":256,\"height\":256,\"caption\":\"dfredborg\"},\"logo\":{\"@id\":\"https:\/\/fredborg.org\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:fredborg.org\",\"https:\/\/www.linkedin.com\/in\/dfredborg\/\",\"https:\/\/x.com\/dfredborg\",\"https:\/\/www.youtube.com\/channel\/UCUNZglLDMjBlOK_T9JtI8UA\"],\"url\":\"https:\/\/fredborg.org\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Azure Service Bus with Business Central - Fredborg","description":"integration between different systems with Business Central and how Azure Service Bus can help with this","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fredborg.org\/?p=1014","og_locale":"en_US","og_type":"article","og_title":"Using Azure Service Bus with Business Central - Fredborg","og_description":"integration between different systems with Business Central and how Azure Service Bus can help with this","og_url":"https:\/\/fredborg.org\/?p=1014","og_site_name":"Fredborg","article_published_time":"2023-07-04T05:30:52+00:00","article_modified_time":"2023-07-04T05:30:53+00:00","og_image":[{"width":1024,"height":576,"url":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus-1024x576.png","type":"image\/png"}],"author":"dfredborg","twitter_card":"summary_large_image","twitter_creator":"@dfredborg","twitter_site":"@dfredborg","twitter_misc":{"Written by":"dfredborg","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fredborg.org\/?p=1014#article","isPartOf":{"@id":"https:\/\/fredborg.org\/?p=1014"},"author":{"name":"dfredborg","@id":"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d"},"headline":"Using Azure Service Bus with Business Central","datePublished":"2023-07-04T05:30:52+00:00","dateModified":"2023-07-04T05:30:53+00:00","mainEntityOfPage":{"@id":"https:\/\/fredborg.org\/?p=1014"},"wordCount":1134,"commentCount":0,"publisher":{"@id":"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d"},"image":{"@id":"https:\/\/fredborg.org\/?p=1014#primaryimage"},"thumbnailUrl":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png","articleSection":["Azure","Business Central"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fredborg.org\/?p=1014#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fredborg.org\/?p=1014","url":"https:\/\/fredborg.org\/?p=1014","name":"Using Azure Service Bus with Business Central - Fredborg","isPartOf":{"@id":"https:\/\/fredborg.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fredborg.org\/?p=1014#primaryimage"},"image":{"@id":"https:\/\/fredborg.org\/?p=1014#primaryimage"},"thumbnailUrl":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png","datePublished":"2023-07-04T05:30:52+00:00","dateModified":"2023-07-04T05:30:53+00:00","description":"integration between different systems with Business Central and how Azure Service Bus can help with this","breadcrumb":{"@id":"https:\/\/fredborg.org\/?p=1014#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fredborg.org\/?p=1014"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fredborg.org\/?p=1014#primaryimage","url":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png","contentUrl":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/07\/Service-Bus.png","width":2560,"height":1440},{"@type":"BreadcrumbList","@id":"https:\/\/fredborg.org\/?p=1014#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fredborg.org\/"},{"@type":"ListItem","position":2,"name":"Using Azure Service Bus with Business Central"}]},{"@type":"WebSite","@id":"https:\/\/fredborg.org\/#website","url":"https:\/\/fredborg.org\/","name":"Fredborg","description":"Business Central and Azure","publisher":{"@id":"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fredborg.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/fredborg.org\/#\/schema\/person\/59a5520cbf04c6bd1267f30b4488e71d","name":"dfredborg","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fredborg.org\/#\/schema\/person\/image\/","url":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/download.png","contentUrl":"https:\/\/fredborg.org\/wp-content\/uploads\/2023\/06\/download.png","width":256,"height":256,"caption":"dfredborg"},"logo":{"@id":"https:\/\/fredborg.org\/#\/schema\/person\/image\/"},"sameAs":["https:fredborg.org","https:\/\/www.linkedin.com\/in\/dfredborg\/","https:\/\/x.com\/dfredborg","https:\/\/www.youtube.com\/channel\/UCUNZglLDMjBlOK_T9JtI8UA"],"url":"https:\/\/fredborg.org\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/posts\/1014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fredborg.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1014"}],"version-history":[{"count":16,"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/posts\/1014\/revisions"}],"predecessor-version":[{"id":1057,"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/posts\/1014\/revisions\/1057"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fredborg.org\/index.php?rest_route=\/wp\/v2\/media\/1058"}],"wp:attachment":[{"href":"https:\/\/fredborg.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fredborg.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fredborg.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}