LogoLogo
HomePricingDocumentation
  • 💿Getting Started
    • Installation and Project Setup
    • Hello Perigee!
    • Perigee Application Design
    • Hello Configuration
    • Hello Logs
    • Hello Integration
    • Troubleshooting
    • Case Studies
  • 📃License + Notice
    • 📂Licensing
    • Notice of Third Party Agreements
  • 🚀Perigee and Beyond
    • Extending - Threads
    • Extending - Loaders
    • ⏳All about CRON
  • 🔮API Generation
    • What is API Generation?
    • API Builder
  • 🗺️Architecting YOUR App
    • Design and Requirements
    • Define Sources
    • Requirements
  • 🧩Core Modules
    • 🌐PerigeeApplication
    • 🪡Thread Registry
    • Event Sources
      • Scheduled/Logic
        • CRON Thread
        • Scheduler
        • Sync Agent
      • Watchers
        • SalesForce
        • Sharepoint
        • Directory Watch
        • Directory Notifier
        • IMAP
    • Credential Management
      • Connection Strings
      • Custom Refresh Logic
      • RestSharp Authenticator
      • Credential Store SDK
      • ⁉️Troubleshooting Credentials
    • Integration Utilities
      • HTTP(S) - RestSharp
      • Transaction Coordinator
      • Limiter
      • Watermarking
    • Alert Managers
      • SMS
      • Email
      • Discord
      • Teams
    • File Formats
      • Excel
      • CSV
    • 📁File System Storage
      • File Revision Store
      • Concurrent File Store
      • FileSync + Cache
    • Third Party
      • SmartSheets
      • Microsoft Graph
    • Perigee In Parallel
      • Parallel Processing Reference
      • Extensions
      • GroupProcessor
      • SingleProcessor
    • 🧱Utility Classes
      • Metrics
      • F(x) Expressions
      • Multi-Threaded Processor (Scatter Gather)
      • OpenAI - GPT
      • XML Converter
      • Dynamic Data Table
      • Debounce
      • Thread Conditions
      • Perigee Utility Class
      • Network Utility
      • Lists
      • FileUtil
      • Inclusive2DRange
      • Strings, Numbers, Dates
      • Nested Sets
      • Behavior Trees
      • JsonCompress
      • Topological Sorting
      • DBDownloader
    • 🈁Bit Serializer
  • 📣Examples and Demos
    • API + Perigee
    • 📰Excel Quick Load
    • SalesForce Watcher
    • Report Scheduler
    • Agent Data Synchronization
    • 📩IMAP Echo bot
    • Watch and load CSVs
    • Graph Delegated Authorization + DataVerse
    • Coordinator Demo
    • Azure Service Bus
    • QuickBooks Online
  • 📘Blueprints
    • Perigee With .NET Hosting
    • Web Host Utilities
    • 🔌Plugin Load Context
  • 🎞️Transforms
    • 🌟What is Transforms?
    • 📘Terminology
    • 🦾The Mapping Document
    • 👾Transformation Process
    • 😎Profile
    • 🎒Automation
      • 🕓Package Options
      • 🔳Configuration
    • 🔧Utilities
      • 🧹Clean
      • 📑Map File
      • 🔎File Identification
      • 🗺️Map Generation
      • 🪅Insert Statement Generation
  • 🗃️Transform SDK
    • 👋Quick Start Guide
    • 🥳MapTo
    • 🔌Authoring Plugins
      • 🔘File IO Process
      • 📢Data Quality
      • 🟢Transform Process
    • SDK Reference
      • 🔘FileIOProcessData
      • 📢DataQualityContext
      • 🎛️TransformDataContext
      • 🏅TransformResult
Powered by GitBook
On this page
  • Azure Service Bus Demo
  • Azure Service Bus Setup
Export as PDF
  1. Examples and Demos

Azure Service Bus

PreviousCoordinator DemoNextQuickBooks Online

Last updated 2 years ago

Azure Service Bus Demo

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 Service Bus Setup

  1. Install the package: Azure.Messaging.ServiceBus

  2. Then

  3. Copy the code over and configure the settings

  4. Run and modify!

PerigeeApplication.ApplicationNoInit("SPA", (c) =>
{
    //Service processor
    c.AddAsync("Service Processor", async (ct, l) => {

        await using var clientSB = new ServiceBusClient(c.GetValue<string>("SPA:queueConnection"));
        await using ServiceBusProcessor processor = clientSB.CreateProcessor(c.GetValue<string>("SPA:queueName"), 
            new ServiceBusProcessorOptions { AutoCompleteMessages = false, MaxConcurrentCalls = 1 }
            );

        //When a message is received:
        processor.ProcessMessageAsync += async (args) =>
        {
            //TODO: Write process code here!!
            
            //Then complete
            await args.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());
            return Task.CompletedTask;
        };

        //Start the process and delay until cancelled
        await processor.StartProcessingAsync(ct);
        while (PerigeeApplication.delayOrCancel(5000, ct)) { }

        //Cancel request: DO NOT send token here, it will cancel the cancel operation.
        await processor.StopProcessingAsync();
        l.LogInformation("Processor stop completed");
        
    }).LinkToConfig("SPA:enabled");
});

And the appsettings.json:

{
  "ConnectionStrings": {    
  },
  "SPA": {
    "queueConnection": "Endpoint=sb://abcdefg.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=ReplaceMe",
    "queueName": "myqueuedemo1",
    "enabled": true,
  },
  "Perigee": { "HideConsole": false },
  "Serilog": {
    "MinimumLevel": "Information",
    "WriteTo": [
      {
        "Name": "Console",
        "Args": {
          "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}]({ThreadName}) {Message:lj}{NewLine}{Exception}"
        }
      }
    ]
  }
}
Azure Portal
install perigee
📣
Page cover image