IM3.AzureServiceBusSender
1.0.0
dotnet add package IM3.AzureServiceBusSender --version 1.0.0
NuGet\Install-Package IM3.AzureServiceBusSender -Version 1.0.0
<PackageReference Include="IM3.AzureServiceBusSender" Version="1.0.0" />
paket add IM3.AzureServiceBusSender --version 1.0.0
#r "nuget: IM3.AzureServiceBusSender, 1.0.0"
// Install IM3.AzureServiceBusSender as a Cake Addin
#addin nuget:?package=IM3.AzureServiceBusSender&version=1.0.0
// Install IM3.AzureServiceBusSender as a Cake Tool
#tool nuget:?package=IM3.AzureServiceBusSender&version=1.0.0
Company: IMobile3 / TSYS Author: Steven Wickers Email: swickers@imobile3.com Date: 09/2018
Specs: This application will send messages to a given Azure Service Bus. Please see IM3.AzureServiceBusReader package to read messages.
Dependencies: .Net Core ^2.1 Microsoft.Azure.ServiceBus ^3.1.0
Required: To create a reference to the ServiceBusSender the following must be supplied: 1. Service Bus Connection String 2. Service Bus Queue Name
Note: The ServiceBusSender constructor is overloaded which can take a service bus connection string and/or Service Bus Queue name. Then reason why the service bus name is optional is to allow the caller to easily switch between Queue repositories without creating any addition references.
SendMessagesAsync Method: There is only one exposed methods called SendMessagesAsync which takes only a string. The return value will be either 200 → "Message Sent" 400 with error message.
Additional Reading: Read the following Microsoft Article on how to setup Azure and to write and read from the Azure Service Bus.
https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues
Example API Wire-up :
1. Add Azure settings in app setting Json file:
"AzureBusSettings":{
"ServiceBusConnectionString": "Endpoint=CreatedWithinYourAzureAccount",
"ServiceBusQuerName": "NameOfQueque"
},
2. In the setup file add the following lines:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
//Get the Azure Bus Setting
var azureSettins = Configuration.GetSection("AzureBusSettings");
//Wire-up the Service
services.AddSingleton<IServiceBusSender>(new
ServiceBusSender(azureSettins["ServiceBusConnectionString"],
azureSettins["ServiceBusQuerName"]));
}
3. Send the Message
Note: status return type is of type Task tuple of (bool, string)
[HttpPost]
public async Task<ActionResult> SendMessage(string Message)
{
//Send message to Azure Service Bus
var status = await _bus.SendMessagesAsync(Message);
if (!status.Item1)
{
return BadRequest(status.Item2);
}
return Ok(status.Item2);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.1
- Microsoft.Azure.ServiceBus (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 1,237 | 9/20/2018 |