LogoLogo
CommunitySupport PortalYouTubeStart a free trial
  • Welcome
  • Commerce Engine
  • Orchestration Engine
  • API Documentation
  • Release Notes
  • Changelog
  • Commerce Engine
  • Getting Started
    • General Concepts of Emporix
    • Creating your first tenant
    • Developer Portal
      • Manage Users
      • Manage API Keys
      • Tenant List
      • My Account
      • Manage Showcase and Sample Data
  • Customer Use Cases
    • Commerce Use Cases
      • Quote Process
      • Orders
      • Coupons and Redeeming Rewards
      • Returns
      • Payments
      • User Management and Approvals
      • Customer Social Login
      • Personalized Commerce - Customer Segments
      • Company Shared Orders and Customer Groups
    • Automated Use Cases
      • First Registration Coupon
      • Availability and Warehouse Assignment
      • Quote and Order Entry Automation
  • System Management
    • Introduction
    • Authentication and Authorization
      • Identity and Access Management (IAM)
      • Auth0
      • Emporix Single Sign-On (SSO)
    • Webhook Event Publishing
      • HTTP Webhook Strategy - HMAC Configuration
      • HTTP Webhook Strategy - Integration with Azure Service Bus
      • HTTP Webhook Strategy - Integration with Amazon Simple Queue Service (SQS)
    • Search
      • Universal Search Connector
      • Search Configuration
      • Indexing Service
    • Optimistic Locking
  • Extensibility and Integrations
    • Extensibility Cases
      • External Products, Pricing and Fees
      • Enabling Custom Extensions
    • Integrations
      • SAP Integration
    • Payment Systems
      • PayPal
      • Saferpay
      • Spreedly Gateway
      • Unzer
    • Third Party Add-Ons
      • Emporix Contentful App
      • Emporix Builder.io Plugin
      • Magnolia Emporix Connector
      • Zendesk Emporix Connect
    • Powered by AI
      • AI Smart Config
      • AI Smart Import
  • Core Commerce
    • Introduction
    • AI Assistance
    • Carts
    • Catalogs
    • Categories
    • Coupons
    • Customer Management
      • Approvals
      • Assisted Buying
      • Customer Groups
      • Customer Segments
    • Data Localization
    • Delivery Cycle Management
    • Mixin Schemas
    • Media Management
    • Orders
      • Shared Orders
    • Pricing
      • Pricing (Legacy)
    • Products
      • Availability, location, and stock levels
      • Brands
      • Labels
    • Quotes
    • Returns
    • Reward Points Management
    • Sites
    • Tax Classes
      • Tax classes (Legacy)
    • Measurement Units
  • Management Dashboard
    • Introduction
    • Customer Management
      • Companies
      • Customers
      • Groups
      • Segments
      • Coupons
    • Quotes
      • Quotes
      • Status Codes
    • Orders
      • Orders
      • SEPA
      • Returns
    • Catalogs
      • Catalogs
      • Categories
    • Products
      • Products
      • Product Templates
      • Labels
      • Suppliers
      • Brands
      • AI for a Product Description
    • Pricing
      • Price Models
      • Price Lists
    • Settings
      • Sites
      • Shipping Zones and Methods
      • Delivery Times
      • Units
      • Tax
      • Countries
      • Currencies
      • Languages
      • System Preferences
      • Custom Entities
      • Mixin Schemas
    • Administration
      • Users and Groups
      • Extensions
      • API Statistics
      • Webhooks
    • Extensions
    • Custom Instances
  • Additional Resources
    • Glossary
    • Videos
    • Emporix Community
Powered by GitBook
LogoLogo

Resources

  • Emporix.com
  • Developer Policy
  • Terms of Use

Find us

  • LinkedIn

© 2025 Emporix. All Rights Reserved.

On this page
  • Preparing Azure infrastructure
  • Azure Service Bus
  • Azure function
  • Configuring Emporix webhooks
  • Creating product

Was this helpful?

Export as PDF
  1. System Management
  2. Webhook Event Publishing

HTTP Webhook Strategy - Integration with Azure Service Bus

See the example integration with Azure Service Bus through webhooks.

Thanks to HTTP webhook strategy, you can choose the event service that enables communication between Emporix and external systems. This article serves as an example demonstrating how you can connect Azure Service Bus to receive events notifications from Emporix. Follow the steps to set up the connection on both sides. Adjust the actual implementation to your needs. Azure Service Bus is a messaging service that allows for communication between decoupled systems, so it can serve as a solution to connect Emporix with some other systems in your company through the webhooks functionality.

Preparing Azure infrastructure

The integration between Emporix and Azure Service Bus in this example will use Azure Function that will act as a consumer of webhook events coming from Emporix. The Azure Function will receive the HTTP request, validate HMAC signature and send the request body to the given queue.

Azure Service Bus

To create Azure Service Bus, go to the Azure Portal.

Follow the steps described in the Microsoft documentation Use Azure portal to create a Service Bus namespace and a queue.

  1. Create a Service Bus called webhooking and a queue called webhook.

  2. Save the Connection String that is present in the Shared access policies section.

Azure function

  1. Create a Function App.

Follow the steps described in the Microsoft documentation Create your first function in the Azure portal.

In this example, the function uses NodeJS and JavaScript.

  1. Create the function locally and then deploy it to Azure.

Follow the steps described in the Microsoft documentation Develop Azure Functions locally using Core Tools.

  1. Create a new project:

func new --template "Http Trigger" --name MyHttpTrigger2
  1. Modify the generated code.

    a. Add a new dependency to package.json:

    "@azure/service-bus": "^7.0.0"

    b. Execute npm install to apply the change.

    c. Provide the required information in the function's code so that the function sends the requests to Azure Service Bus. Let's take a look and analyze the function’s code:

    const { app } = require('@azure/functions');
    const { ServiceBusClient } = require("@azure/service-bus");
    const crypto = require('crypto');
    
    const connectionString = "FILL_IT" // i
    const queueName = "webhook"; // ii
    
    const secretKey = 'password123'; // iii
    
    app.http('MyHttpTrigger2', {
        methods: ['GET', 'POST'],
        authLevel: 'anonymous',
        handler: async (req, context) => {
    
            const serviceBusClient = new ServiceBusClient(connectionString);
            const sender = serviceBusClient.createSender(queueName);
        
            const body = JSON.stringify(req.body);
            context.log(body);
            const hmac = crypto.createHmac('sha256', secretKey);
            hmac.update(body);
        
            const computedHmac = hmac.digest('base64');
        
            
            if (computedHmac !== req.headers['emporix-event-signature']) {
                context.res = {
                    status: 401,
                    body: "HMAC validation didn't pass.",
                };
            }
        
            try {
                const messageBody = req.body;
                const message = {
                    body: messageBody,
                };
        
                await sender.sendMessages(message); // iv
                context.log("Message successfully sent");
                context.res = {
                    status: 200,
                    body: "Message sent to the queue",
                };
            } finally {
                await sender.close();
                await serviceBusClient.close();
            }
        }
    });

\

Pay attention to the marked lines and provide relevant information:

i. connectionString constant - replace the value with the connection string to your Azure Service Bus instance. Find it in the Shared access policies section in Azure Portal.

ii. queueName constant - provide the value of the queue you created. Here, it equals webhook just as the queue we created.

iii. secretKey constant - provide the secret phrase for HMAC validation. You need to specify the same value in the webhooks HTTP configuration in the later steps. Here, we defined it as password123.

Find more information on how to configure HMAC validation in HTTP Webhook Strategy - HMAC Configuration.

iv. when HMAC validation passes, the message body is sent with the request to the queue.

  1. Deploy the function to Azure by calling the command:

func azure functionapp publish <APP_NAME>

Configuring Emporix webhooks

Now, prepare Commerce Engine.

  1. Configure webhooks to send the events as HTTP POST requests. Use the following curl and provide relevant information in the placeholders:

curl -L 'https://api.emporix.io/webhook/{{tenant}}/config' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '{
    "code": "http",
    "active": true,
    "provider": "HTTP",
    "configuration": {
        "secretKey": "password123",
        "destinationUrl": "{{destinationUrl}}"
    }
}'

Placeholders to fill in:

  • tenant - name of your production tenant

  • token - your generated Emporix access token with relevant scopes

  • destinationUrl - link to your Azure Function

  1. Subscribe to a chosen event. In this example, we subscribe to product creation event (remember to replace the values in the placeholders):

curl -L -X PATCH 'https://api.emporix.io/webhook/{{tenant}}/event-subscriptions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '[
  {
    "eventType": "product.created",
    "action": "SUBSCRIBE",
    "fieldsToSubscribe": [
      "name"
    ],
    "fieldsToUnsubscribe": [
      "description"
    ]
  }
]
 '

Creating product

The integration is ready. To see it in action, let's create a product.

Create a product with the following curl request providing your relevant details in the placeholders:

curl -L 'https://api.emporix.io/product/{{tenant}}/products/' \
-H 'Content-Language: en' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '{
    "name": "Test product for documentation",
    "code": "unique",
    "description": "product description",
    "published": false
}'

After the product is created the event is sent. The webhook service consumes the event and sends it as HTTP request to the specified destinationUrl, which is the Azure Function. The Azure Function receives the request and sends it to Azure Service Bus Queue.

PreviousHTTP Webhook Strategy - HMAC ConfigurationNextHTTP Webhook Strategy - Integration with Amazon Simple Queue Service (SQS)

Last updated 1 month ago

Was this helpful?