This demo will allow you to connect to service bus and retrieve messages. It's configured only for 1 concurrent message at a time, but is easily configurable.
Setup and configuration for your service bus can be done on the Azure Portal.
PerigeeApplication.ApplicationNoInit("SPA", (c) =>{ //Service processorc.AddAsync("Service Processor",async (ct, l) => {awaitusingvar clientSB =newServiceBusClient(c.GetValue<string>("SPA:queueConnection"));awaitusingServiceBusProcessor processor =clientSB.CreateProcessor(c.GetValue<string>("SPA:queueName"),newServiceBusProcessorOptions { AutoCompleteMessages =false, MaxConcurrentCalls =1 } ); //When a message is received:processor.ProcessMessageAsync+=async (args) => { //TODO: Write process code here!! //Then completeawaitargs.CompleteMessageAsync(args.Message); //Or abandon //await args.AbandonMessageAsync(args.Message); }; //When an uncaught error is thrown, (write good code and don't let this happen!)processor.ProcessErrorAsync+= (args) => {var l =c.GetLogger<ServiceBusProcessor>();l.LogError("Error: {Source}",args.ErrorSource);l.LogError("Error: {FQN}",args.FullyQualifiedNamespace);l.LogError("Error: {Entity}",args.EntityPath);l.LogError("Error: {Exception}",args.Exception.ToString());returnTask.CompletedTask; }; //Start the process and delay until cancelledawaitprocessor.StartProcessingAsync(ct);while (PerigeeApplication.delayOrCancel(5000, ct)) { } //Cancel request: DO NOT send token here, it will cancel the cancel operation.awaitprocessor.StopProcessingAsync();l.LogInformation("Processor stop completed"); }).LinkToConfig("SPA:enabled");});