Publishing a Payload as a message to an Azure Environment through IBMi
As organizations strive to harness the power of the cloud,
The question of how to efficiently transfer data between on-premises systems, such as IBMi, and the cloud becomes paramount.
Today, we explore a vital aspect of this journey:
Publishing payloads as messages to Azure, Microsoft’s formidable cloud platform.
Introduction
Nowadays, systems and applications must communicate efficiently to operate effectively. To manage their data and services, many businesses use multiple technologies and platforms. However, integrating these various components can be a challenge. An IBMi system is often combined with an Azure environment by sending data or payloads there. The purpose of this blog is to demonstrate how to publish a payload to an Azure environment through IBMi systems.
Benefits of Using Payloads as Message
- Seamless Integration: Integrating IBMi with Azure allows for seamless data exchange between on-premises and cloud environments. This smooth integration streamlines business processes and reduces data
- Flexibility: Azure offers a wide range of services and tools to meet diverse business needs. Whether you need real-time data processing, analytics, or storage, Azure can adapt to your requirements.
- Cost-Efficiency: Azure’s pay-as-you-go pricing model means you only pay for the resources you use. This eliminates the need for significant upfront hardware investments and allows for cost-effective
Pre-Requisites
- Access to Azure Environment: Get access to the Azure environment so that you can create Azure Queues, Topics, Subscriptions, etc.
- Azure Queue/Topic Name: Identify the queue (or) topic in the Azure environment where the message will be published.
- Queue: Using an authorized Azure environment, the queue will be created with a name and will be processed in a FIFO order.
Queues provide one-to-one communication between messages and their consumers. There can only be one consumer per queue, so a message can only be processed by one of the consumers.
Queues offer First In, First Out (FIFO) message delivery to one or more competing consumers. That is, receivers typically receive and process messages in the order in which they were added to the queue, which means the first message delivered into the Queue will be the first one to be retrieved by the receiver. Each message is received and processed by the consumer only once.
- Topic: A topic is a ‘subscriber’ created within an Azure environment with a name so messages can be sent to multiple subscribers at once.
In contrast to a queue, a topic (and subscriptions) provides a one-to-many relationship between each message and consumers. To scale to large numbers of recipients, it follows the publish/subscribe pattern (pub/sub). All published messages are made available to subscribers registered with the topic.
Publishers send messages to the topic in the same way they send them to the queue, with one slight difference: Topics can contain more than one message. independent subscriptions. A subscriber to a Topic can receive a copy of each message sent to that Topic.
Consumers don’t receive messages directly from the topic. Instead, consumers receive messages from subscriptions of the topic.
- Subscriber Details: Azure Subscriptions are a logical unit of Azure services that are linked to an Azure account.
To use Azure’s cloud-based services, you must have a subscription, which serves as a billing unit for Azure resources.
You can use Azure subscriptions to define the following boundaries: Billing boundary: This subscription type defines how resources are billed. You can create different subscriptions for different billing requirements, and Azure sends separate billing resources for each subscription.
- App Registration Details: An App Registration (Application) is an object in Azure AD that describes the application. This is an application definition that includes several elements, such as name, logo, publisher, API dependency (OAuth), redirect URIs, role metadata, SSO metadata, published APIs, etc.
The Azure App registration process is an easy and powerful way to configure authentication and authorization workflows for a wide variety of clients.
- Client ID and Client Secret: These details can be fetched while creating an App registration and these Client ID and Client Secret values are used to fetch the Authentication bearer token.
- Authentication Bearer Token: It is a token that is used to authenticate the AS400 system to connect and post the JSON format message into an Azure Environment into a specific Queue/Topic.
This is generated at runtime based on the valid Client ID and Client Secret provided.
AS400 System Process
Disclaimer: To process this data, YAJL libraries were used.
The RPGLE program in the AS400 system needs to be prepared by following the steps in the Prerequisite session.
1. The first step is to generate data that needs to be sent in JSON format.
Example:
2. Bypassing the ClientID and Client Secret values to Azure Environment, you can get an authorization token.
To get this token pass the Content – type as multipart/form-data format.
Example: Below is a sample of how multipart/form data can be used to build the required body string
By using http_SetOption, set the content type to the following
3. A function called http_req is used to perform any HTTP request and get input and output from a string.
Here Output variable consists of the access token/authorization token value.
4. Upon receiving the Authorization bearer token, you can send a JSON format message along with the token to Azure Queue/Topic.
***Note: If it’s a Topic pass the appropriate Subscriber details as a header value while executing the URL as below.
The final HTTP request function to send a message into Azure Topics/Queues can be found here.
***Note: RC value of 201 indicates a successful post.
Conclusion
Publishing a payload as a message to an Azure environment from IBMi can significantly enhance the capabilities of your business applications. By following these steps and choosing the right Azure service for your needs, you can seamlessly integrate your IBMi system with the Azure cloud, enabling efficient data exchange and processing. Whether you’re working with customer data, IoT devices, or any other use case, this integration can help you leverage the power of Azure to drive your business forward.
How can we help you?
We have hundreds of highly-qualified, experienced experts working in 70+ technologies.