Skip to content

Commit 37fe03a

Browse files
committed
Update
1 parent 299b4c1 commit 37fe03a

File tree

6 files changed

+32
-158
lines changed

6 files changed

+32
-158
lines changed

articles/event-grid/mqtt-how-to-http-publish.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ ms.custom:
1515
- ai-gen-description
1616
---
1717

18-
# How to Publish MQTT Messages via HTTP with Azure Event Grid
18+
# How to Publish MQTT Messages via HTTP with Azure Event Grid (preview)
1919
Azure Event Grid now supports publishing MQTT messages via HTTP, enabling backend systems to send messages to devices without maintaining persistent MQTT connections. This approach simplifies integration for applications that prefer stateless communication, uses secure authentication with Entra ID, and provides scalable, reliable delivery to MQTT clients. In this article, you learn how to use the HTTP Publish API, obtain the necessary credentials, and verify message delivery using popular tools like Bruno, and MQTTX.
2020

21+
> [!NOTE]
22+
> This feature is currently in preview.
23+
2124
This article explains how to publish MQTT messages via HTTP with Azure Event Grid.
2225

2326
## Get Your Connection Details
@@ -35,7 +38,7 @@ az account get-access-token --resource=https://<namespaceFQDN> --query accessTok
3538

3639
Save this token to use in the `Authorization: Bearer <TOKEN>` header.
3740

38-
# [cURL](#tab/curl)
41+
### [cURL](#tab/curl)
3942

4043
Here’s an example cURL command to simulate the HTTP Publish.
4144

@@ -57,7 +60,7 @@ In this sample command:
5760
- Add optional headers for QoS, retain flag, response topic, user properties.
5861
- Payload goes in the request body.
5962

60-
# [Bruno](#tab/brno)
63+
### [Bruno](#tab/brno)
6164

6265
## Import to Bruno
6366
1. Open Bruno.
Lines changed: 19 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Publish MQTT Messages via HTTP with Azure Event Grid
2+
title: HTTP Publish of MQTT messages with Azure Event Grid
33
description: Publish MQTT messages via HTTP with Azure Event Grid for scalable server-to-device communication. Learn how to use the HTTP Publish API effectively.
44
#customer intent: As a backend developer, I want to publish MQTT messages via HTTP so that I can integrate with Azure Event Grid without maintaining persistent MQTT sessions.
55
author: spelluru
@@ -15,31 +15,34 @@ ms.custom:
1515
- ai-gen-description
1616
---
1717

18-
# Overview
18+
# HTTP Publish of MQTT messages with Azure Event Grid (preview)
1919

2020
The Azure Event Grid MQTT Broker HTTP Publish API empowers customers to publish MQTT messages using standard HTTP requests. This complements direct MQTT client connections, providing a simple and scalable option for server-side systems that prefer HTTP for server-to-device command-and-control, updates, or retained message management.
2121

22+
> [!NOTE]
23+
> This feature is currently in preview.
24+
2225
Key benefits:
2326

2427
- Allows backend services to send MQTT messages without keeping persistent MQTT sessions open.
2528
- Helps protect broker stability by limiting per-client MQTT sessions.
2629
- Ensures consistent message processing for both MQTT and HTTP-originated messages.
2730

28-
# When to Use HTTP Publish
31+
## When to Use HTTP Publish
2932

3033
Consider HTTP Publish when:
3134

3235
- Your backend services are HTTP-native and need to send device commands or updates over MQTT.
3336
- You want to manage retained messages without opening an MQTT connection.
3437
- You need to scale up publish capacity without exhausting session limits.
3538

36-
# How It Works
39+
## How It Works
3740

3841
1. HTTP clients issue an HTTP POST request with MQTT publish details.
3942
1. Event Grid maps HTTP request parts to standard MQTT PUBLISH packet properties.
4043
1. Messages flow through the Event Grid routing and enrichment pipeline, ensuring delivery guarantees and applying any enrichment or transformation.
4144

42-
# Example: MQTT PUBLISH Equivalent
45+
## Example: MQTT PUBLISH Equivalent
4346

4447
```http
4548
PUBLISH Topic Name: devices/CXa-23112/prompt
@@ -52,7 +55,7 @@ User Property: RequestId = 55f4a7ee-b0b4-4d7f-8eb5-2edba2ced5d7
5255
Payload: Please accept terms of licensing and agreement
5356
```
5457

55-
# Example: HTTP Publish Request
58+
## Example: HTTP Publish Request
5659

5760
```http
5861
POST /mqtt/messages?topic=devices%2FCXa-23112%2Fprompt&api-version=2025-02-15-preview HTTP/1.1
@@ -72,7 +75,7 @@ Please accept terms of licensing and agreement
7275

7376

7477

75-
# Request Parameters
78+
## Request Parameters
7679

7780
This table describes how HTTP request parts map to MQTT PUBLISH packet properties. Refer to the original documentation for full details.
7881

@@ -95,7 +98,7 @@ This table describes how HTTP request parts map to MQTT PUBLISH packet propertie
9598
- Percent-encoding is required for topic and response topic.
9699
- Correlation Data must be base64-encoded.
97100

98-
# High-level steps for using HTTP Publish
101+
## High-level steps for using HTTP Publish
99102

100103
- Step 1: Prepare your Entra ID bearer token for authentication.
101104
- Step 2: Construct your HTTP POST request to your Event Grid MQTT broker endpoint.
@@ -105,14 +108,14 @@ This table describes how HTTP request parts map to MQTT PUBLISH packet propertie
105108
- Step 6: Send the request.
106109
- Step 7: Confirm delivery via logs and metrics in the Event Grid portal.
107110

108-
# Authentication & Authorization
111+
## Authentication & Authorization
109112

110-
- HTTP Publish uses Azure Entra ID for authentication.
113+
- HTTP Publish uses Microsoft Entra ID for authentication.
111114
- Add a Bearer token to the Authorization header.
112-
- The Entra Object ID becomes the MQTT clientId.
115+
- The Microsoft Entra Object ID becomes the MQTT clientId.
113116
- The AuthN/AuthZ model aligns with standard MQTT connections.
114117

115-
# Routing, Enrichment & Observability
118+
## Routing, Enrichment & Observability
116119

117120
- HTTP messages pass through the Event Grid routing pipeline, ensuring consistent routing, enrichment, and delivery guarantees.
118121

@@ -123,148 +126,15 @@ This table describes how HTTP request parts map to MQTT PUBLISH packet propertie
123126
- Source IP
124127
- Auth principal
125128

126-
# Best Practices
129+
## Best Practices
127130

128131
- Use lowercase header keys where possible. HTTP/2 header keys are case-insensitive.
129132
- Monitor throughput — HTTP messages tend to be larger than direct MQTT messages.
130133
- HTTP Publish shares throughput limits with direct MQTT publishes.
131134

132-
# Throttling
135+
## Throttling
133136

134137
Be aware that HTTP Publish counts towards your overall MQTT throughput quota. Monitor your usage to avoid exceeding limits.
135138

136-
137-
## How to use the HTTP Publish feature
138-
139-
### Step 1: Get Your Connection Details
140-
141-
- Namespace fully qualified doamin name (FQDN). Example: `contoso.westus3-1.ts.eventgrid.azure.net`.
142-
- Topic. Example: `devices/CXa-23112/prompt`.
143-
- Entra ID client credentials.
144-
145-
### Step 2: Get a bearer token
146-
Run the following Azure CLI command to get a bearer token.
147-
148-
```bash
149-
az account get-access-token --resource=https://<namespace> --query accessToken -o tsv
150-
```
151-
152-
### Step 3: Import to Postman or Bruno
153-
Use steps from the Postman (or) Bruno section, depending on the tool you are comfortable with.
154-
155-
#### Postman
156-
157-
1. Open Postman.
158-
2. Select **Import** → select `EventGrid_HTTP_Publish_Postman_Collection.json`.
159-
3. Go to **Variables** tab:
160-
- Replace `{{namespace}}` with your namespace FQDN.
161-
- Replace `{{topic}}` with your MQTT topic.
162-
- Replace `{{entra_token}}` with your token from Step 2.
163-
4. Select **Send**. You should get 202 or 204.
164-
165-
#### Bruno
166-
167-
1. Open Bruno.
168-
2. Select **Import Collection**, and then select `EventGrid_HTTP_Publish_Postman_Collection.json`.
169-
3. Go to **Variables** tab:
170-
- Replace `{{namespace}}` with your namespace FQDN.
171-
- Replace `{{topic}}` with your MQTT topic.
172-
- Replace `{{entra_token}}` with your token from Step 2.
173-
174-
### Step 4: Verify in MQTTX
175-
176-
- Open MQTTX, connect using your broker’s endpoint, TLS, and your normal MQTT auth.
177-
- Subscribe to the topic you used in the HTTP POST.
178-
- You should see your payload appear.
179-
180-
### Troubleshooting
181-
182-
- **401 Unauthorized?** — Refresh your token.
183-
- **403 Forbidden?** — Check your topic or permissions.
184-
- **Message doesn’t appear?** — Ensure topic is percent-encoded in the URL, check broker routing config, and verify you’re using the same namespace.
185-
186-
187-
# Tutorials:
188-
189-
## Option 1: Using cURL Command
190-
191-
### Step 1: Get Your Connection Details
192-
193-
- **Event Grid Namespace**: e.g., contoso.westus3-1.ts.eventgrid.azure.net
194-
- **Topic**: e.g., devices/CXa-23112/prompt
195-
- **Entra Client ID** and Tenant: for getting your bearer token.
196-
- **Audience (Resource)**: your Event Grid Namespace URL.
197-
198-
### Step 2: Get an Entra ID Token
199-
200-
Use **Azure CLI** or your preferred flow to get a token:
201-
202-
```bash
203-
az account get-access-token \
204-
--resource=https://contoso.westus3-1.ts.eventgrid.azure.net \
205-
--query accessToken \
206-
-o tsv
207-
```
208-
209-
Save this token to use in the Authorization: Bearer `<TOKEN>` header.
210-
211-
### Step 3: Prepare Your HTTP POST Request
212-
213-
Here’s an example using curl to simulate the HTTP Publish.
214-
215-
```bash
216-
curl -X POST "https://contoso.westus3-1.ts.eventgrid.azure.net/mqtt/messages?topic=devices%2FCXa-23112%2Fprompt&api-version=2025-02-15-preview" \
217-
-H "Authorization: Bearer <ENTRA_TOKEN_HERE>" \
218-
-H "mqtt-qos: 1" \
219-
-H "mqtt-retain: 0" \
220-
-H "mqtt-response-topic: devices%2FCXa-23112%2Freply" \
221-
-H "mqtt-correlation-data: PlXCscK2wrbCuy8=" \
222-
-H "mqtt-user-properties: W3siVXJnZW5jeSI6ImFsZXJ0In0seyJSZXF1ZXN0SWQiOiI1NWY0YTdlZS1iMGI0LTRkN2YtOGViNS0yZWRiYTJjZWQ1ZDcifV0=" \
223-
-H "Content-Type: text/plain;charset=UTF-8" \
224-
--data-raw "Please accept terms of licensing and agreement"
225-
```
226-
227-
### Step 4: Verify Publish with MQTT Client
228-
229-
Use **MQTTX** or any MQTT library (like paho-mqtt Python) to subscribe to the same topic to confirm delivery.
230-
231-
#### Example MQTTX Steps
232-
233-
1. Create a new connection in MQTTX:
234-
- Host: contoso.westus3-1.ts.eventgrid.azure.net
235-
- Port: 8883 (TLS)
236-
- Client ID: same as your Entra Object ID.
237-
- Username/Password: N/A — use certificate or token auth if configured.
238-
2. Subscribe to devices/CXa-23112/prompt.
239-
3. Run the HTTP Publish and watch for the message in MQTTX.
240-
241-
### Step 5: Validate Success
242-
243-
- If the publish succeeds, you’ll see:
244-
- **HTTP Response**: 204 No Content or 202 Accepted (depending on routing rules).
245-
- MQTT client sees the message instantly.
246-
247-
#### Expected log in your MQTT client
248-
249-
```text
250-
Topic: devices/CXa-23112/prompt
251-
Payload: Please accept terms of licensing and agreement
252-
QoS: 1
253-
```
254-
255-
### Step 6: Handle Failures
256-
257-
- If the token is missing or expired: You’ll get 401 Unauthorized.
258-
- If the topic is invalid or you don’t have rights: 403 Forbidden.
259-
- If routing fails internally: 500 Internal Server Error with diagnostic info.
260-
261-
💡 Check logs in Event Grid Metrics and Diagnostic Logs for delivery status.
262-
263-
## Option 2: Using Postman or Bruno
264-
265-
This helps you test the HTTP Publish feature using:
266-
267-
- Postman or Bruno collection (provided).
268-
- MQTTX or your MQTT client to verify delivery.
269-
- Entra ID for secure auth.
270-
139+
## Next step
140+
See [How to publish MQTT messages using HTTP with Azure Event Grid](mqtt-how-to-http-publish.md).

articles/event-grid/mqtt-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ An MQTT retain message is used to store the last known good value of a topic on
123123

124124
### HTTP Publish(preview)
125125

126-
HTTP Publish enables applications to publish MQTT messages to Azure Event Grid MQTT Broker over a simple HTTPS POST request, without maintaining an active MQTT session. It’s best suited for scenarios where MQTT clients are not feasible or necessary—such as serverless functions, cloud services, or backend applications—allowing event-driven architectures to inject MQTT messages reliably and securely. Common use cases include publishing device commands, alerts, or control signals from Azure Functions, Logic Apps, or API integrations.
126+
HTTP Publish enables applications to publish MQTT messages to Azure Event Grid MQTT Broker over a simple HTTPS POST request, without maintaining an active MQTT session. It’s best suited for scenarios where MQTT clients are not feasible or necessary—such as serverless functions, cloud services, or backend applications—allowing event-driven architectures to inject MQTT messages reliably and securely. Common use cases include publishing device commands, alerts, or control signals from Azure Functions, Logic Apps, or API integrations. For more information, see [HTTP Publish of MQTT messages in Azure Event Grid](mqtt-http-publish.md).
127127

128128
## Concepts
129129
See the following articles for concepts of MQTT broker in Azure Event Grid:

articles/event-grid/mqtt-retain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.custom:
1111
- ai-gen-description
1212
---
1313

14-
## MQTT retain support in Azure Event Grid (preview)
14+
# MQTT retain support in Azure Event Grid (preview)
1515
The MQTT Retain feature in Azure Event Grid (Preview) ensures that the last known good value of a topic is stored and readily available for new subscribers. This capability allows new clients to instantly receive the most recent message upon connection, eliminating the need to wait for the next publish. It is beneficial in scenarios such as device state reporting, control signals, or configuration data, where timely access to the latest message is critical.
1616

1717
This article provides an overview of how the MQTT Retain feature works, its billing implications, storage limits, message deletion methods, and retain management considerations.

articles/event-grid/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Here are some highlights of MQTT messaging support in Azure Event Grid:
5656
- MQTT over WebSockets - Enable connectivity for clients in firewall-restricted environments.
5757
- Custom domain names - Allows users to assign their own domain names to Event Grid namespace's MQTT endpoints, enhancing security and simplifying client configuration.
5858
- Client Life Cycle events - Allow applications to react to events about the client connection status or the client resource operations.
59-
- **HTTP Publish** - Enables devices and services to send MQTT messages to Azure Event Grid over HTTPS, simplifying integration with non-MQTT clients.
59+
- [HTTP Publish](mqtt-http-publish.md) - Enables devices and services to send MQTT messages to Azure Event Grid over HTTPS, simplifying integration with non-MQTT clients.
6060
- [MQTT Retain](mqtt-retain.md) - Ensures the last known message on a topic is automatically delivered to new subscribers, enabling instant state synchronization.
6161

6262
For more information about MQTT broker, see the following articles:

articles/event-grid/whats-new.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ The following features of Event Grid Namespaces moved from public preview to gen
1616

1717
- [OAuth 2.0 (JSON Web Token) authentication ( Refresh- with Direct upload of (Privacy-Enhanced Mail) PEM certificates)](authenticate-with-namespaces-using-json-web-tokens.md#configure-oauth-20-jwt-authentication-settings-on-your-event-grid-namespace---direct-upload)
1818
- [Custom Webhook Authentication](authenticate-with-namespaces-using-webhook-authentication.md)
19-
- [MQTT Compliance – Supports assigned client identifier](mqtt-support.md#assigned-client-identifiers-preview).
19+
- [MQTT Compliance – Supports assigned client identifier](mqtt-support.md#assigned-client-identifiers).
2020
- [MQTT limit change](quotas-limits.md) – Inbound MQTT publishing requests per session: 1,000 messages per second.
2121

2222
The following features are released in Preview:
2323
- MQTT Compliance – [MQTT Retain support](mqtt-retain.md).
24-
- HTTP Publish capability.
24+
- [HTTP Publish of MQTT messages in Azure Event Grid](mqtt-http-publish.md).
25+
2526

2627
## May 2025
2728
The following features of Event Grid Namespaces moved from public preview to general availability (GA).
@@ -49,7 +50,7 @@ The following features are released in Preview:
4950
- [OAuth 2.0 (JSON Web Token) authentication ( Refresh- with Direct upload of (Privacy-Enhanced Mail) PEM certificates)](authenticate-with-namespaces-using-json-web-tokens.md#configure-oauth-20-jwt-authentication-settings-on-your-event-grid-namespace---direct-upload)
5051
- [Custom Webhook Authentication](authenticate-with-namespaces-using-webhook-authentication.md)
5152
- [Send MQTT events directly to Microsoft Fabric using Azure Event Grid ](mqtt-events-fabric.md)
52-
- MQTT Compliance – [Supports assigned client identifier](mqtt-support.md#assigned-client-identifiers-preview).
53+
- MQTT Compliance – [Supports assigned client identifier](mqtt-support.md#assigned-client-identifiers).
5354
- [MQTT limit change](quotas-limits.md) – Inbound MQTT publishing requests per session: 1,000 messages per second.
5455

5556
## November 2024

0 commit comments

Comments
 (0)