Official Content

The MessageBrokerProvider external object under the AzureServiceBus module is used to establish a connection to a Service Bus (Queue or Topic) using the Message Broker API.

image_202382520429_1_png

Properties

It doesn't have any.

Methods

Connect

A static method that allows instantiating a MessageBroker using dynamic data. The method connects using a connection string and returns a MessageBroker to be used to send and receive messages from the Service Bus.

Return value MessageBroker external object
Parameters queueName:VarChar, connectionString:VarChar, sessionEnabled:Boolean, receiverOptions: BrokerReceiverOptions, senderIdentifier:VarChar, errorMessages:GeneXus.Common.Messages, success:Boolean.

sessionEnabled: True if it's a session-enabled Service Bus queue.
senderIdentifier: Sets the ID for send operations. This can be used to correlate logs and exceptions.
BrokerReceiverOptions is considered only for non-session enabled queues.

Connect

Return value MessageBroker external object
Parameters topicName:VarChar, subscriptionName:VarChar, connectionString:VarChar, sessionEnabled:Boolean, receiverOptions: BrokerReceiverOptions, senderIdentifier:VarChar, errorMessages:GeneXus.Common.Messages, success:Boolean.

sessionEnabled: True if it's a session-enabled Service Bus queue.
senderIdentifier: Sets the ID for send operations. This can be used to correlate logs and exceptions.
BrokerReceiverOptions is considered only for non-session enabled queues.

Connect

Return value MessageBroker external object
Parameters queue:VarChar, connectionString:VarChar, errorMessages:Messages, success:Boolean.

Connect

Return value MessageBroker external object
Parameters topicName:VarChar, subscriptionName:VarChar, connectionString:VarChar, errorMessages:Messages, success:Boolean.

Authenticate

A static method for authenticating to a Service Bus Queue that supports Azure Active Directory (Microsoft Entra ID) authentication. No credentials are passed to the method. See Authenticate using Managed Identities below in this document.

Return value MessageBroker external object
Parameters queueName:VarChar, fullyQualifiedNamespace:VarChar, sessionEnabled:Boolean, receiverOptions: BrokerReceiverOptions, senderIdentifier:VarChar, errorMessages:GeneXus.Common.Messages, success:Boolean.

sessionEnabled: True if it's a session-enabled Service Bus queue.
senderIdentifier: Sets the ID for send operations. This can be used to correlate logs and exceptions.
BrokerReceiverOptions is considered only for non-session enabled queues.

fullyQualifiedNamespace: The fully qualified Service Bus namespace to connect to. This is likely to be similar to {yournamespace}.servicebus.windows.net

Authenticate

Authenticate to a Service Bus Topic that supports Azure AD (Microsoft Entra ID) authentication.

Return value MessageBroker external object
Parameters topicName:VarChar, subscriptionName:VarChar, fullyQualifiedNamespace:VarChar, sessionEnabled:Boolean, receiverOptions: BrokerReceiverOptions, senderIdentifier:VarChar, errorMessages:GeneXus.Common.Messages, success:Boolean.

sessionEnabled: True if it's a session-enabled Service Bus queue.
senderIdentifier: Sets the ID for send operations. This can be used to correlate logs and exceptions.
BrokerReceiverOptions is considered only for non-session enabled queues.

fullyQualifiedNamespace: The fully qualified Service Bus namespace to connect to. This is likely to be similar to {yournamespace}.servicebus.windows.net

Authenticate

Authenticate to a Service Bus Queue that supports Azure AD (Microsoft Entra ID) authentication.

Return value MessageBroker external object
Parameters queue:VarChar, fullyQualifiedNamespace:VarChar, errorMessages:Messages, success:Boolean.

fullyQualifiedNamespace: The fully qualified Service Bus namespace to connect to. This is likely to be similar to {yournamespace}.servicebus.windows.net

Authenticate 

Authenticate to a Service Bus Topic that supports Azure AD (Microsoft Entra ID) authentication.

Return value MessageBroker external object
Parameters topicName:VarChar, subscriptionName:VarChar, fullyQualifiedNamespace:VarChar, errorMessages:Messages, success:Boolean.

fullyQualifiedNamespace: The fully qualified Service Bus namespace to connect to. This is likely to be similar to {yournamespace}.servicebus.windows.net

Authenticate using Managed Identities

Applications can use managed identities to obtain Azure AD (Microsoft Entra ID) tokens without having to manage any credentials.
As Azure documents explain, it is recommended that apps use token-based authentication rather than connection strings when authenticating to Azure resources.

The implementation of the Authenticate methods chains several Token Credential implementations to be tried in order until one succeeds:

  • System-assigned Managed Identity
    Attempts authentication using a managed identity assigned to the deployment environment. This authentication type works for all Azure-hosted environments that support managed identity.
     
  • User-assigned Managed Identity.
    The resource ID to authenticate for a user-assigned managed identity must be set in an environment variable named "AZURE_CLIENT_ID".
     
  • Service Principal. Enables authentication to Azure Active Directory (Microsoft Entra ID) using a client secret or certificate, or as a user with a username and password. See here for more details.
     
  • Azure CLI credentials
    Enables authentication to Azure Active Directory using Azure CLI to obtain an access token (for development environments).

Events

It doesn't have any.

Set connection at runtime using environment variables

Environment variables (encrypted if desired) can be set to indicate connection parameters, instead of passing the values to the methods.

In most cases, it is useful to change the connection at runtime.
First, the environment variables are read and then the value of the parameter passed to the method is taken into account.

The variables may or may not be encrypted. The encryption key should be indicated in the Application.key file in the case of the NET generator.
In Azure, the environment variables are set as App Settings.

The enviroment variables for the methods explained in this document are the following:

  • MESSAGEBROKER_AZURESB_QUEUENAME
  • MESSAGEBROKER_AZURESB_TOPICNAME
  • MESSAGEBROKER_AZURESB_SUBSCRIPTION
  • MESSAGEBROKER_AZURESB_QUEUECONNECTION
  • MESSAGEBROKER_AZURESB_FULLYQUALIFIEDNAMESPACE

See Also

Azure Service Bus.

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant