# Azure Event Grid integration

**URL:** https://forums.losant.com/t/azure-event-grid-integration/5155
**Category:** Help
**Tags:** mqtt
**Created:** [July 17, 2023, 1:09pm UTC](https://forums.losant.com/t/azure-event-grid-integration/5155 "2023-07-17T13:09:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Gambit\_Support](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/gambit_support/32/826_2.png) [@Gambit\_Support](https://forums.losant.com/u/Gambit_Support)
#### Post date: [July 17, 2023, 1:09pm UTC](https://forums.losant.com/t/azure-event-grid-integration/5155/1 "2023-07-17T13:09:38Z")

</div>

We are trying the MQTT integration to Azure Event Grid

> **[Azure Event Grid Namespace MQTT client authentication - Azure Event Grid](https://learn.microsoft.com/en-us/azure/event-grid/mqtt-client-authentication)**
>
> Describes how MQTT clients are authenticated and mTLS connection is established when a client connects to MQTT service.

but it seems it only allows to configure either of Certificate or “Username and Password” authentication.  
Is there a way to configure both?

---

<div class="post-metadata">

### Author: ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)
#### Post date: [July 17, 2023, 2:50pm UTC](https://forums.losant.com/t/azure-event-grid-integration/5155/2 "2023-07-17T14:50:36Z")

</div>

We disallow it in the user interface but do allow the setting of username and password and certificate fields in the same request through our API.

I’m currently setting up an Event Grid in Azure and trying to connect a Losant MQTT integration as a client, as I do not see anything in the documentation that indicates a username and password are necessary to provide along with a certificate. I will get back to you once I learn more.

---

<div class="post-metadata">

### Author: ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)
#### Post date: [July 17, 2023, 7:01pm UTC](https://forums.losant.com/t/azure-event-grid-integration/5155/3 "2023-07-17T19:01:35Z")

</div>

It took some work but I got to the bottom of this.

First, I’ve filed a ticket to also expose the username and password fields when selecting “Certificate” as an authentication method in the MQTT integration; as you have pointed out here, that username field is necessary for one of the two methods of authenticating an Event Grid client connection from a Losant integration.

In the meantime, there are two workarounds:

First, you can use the Losant API directly to [create](https://docs.losant.com/rest-api/integrations/#post) or [update](https://docs.losant.com/rest-api/integration/#patch) an integration and, in the request body, include the `username` property in the `mqttConfig` object alongside your `privateKey` and `certificate` properties. The username should match one of the Client Names in your Event Grid configuration.

Alternatively, you can configure your Event Grid to use an “[alternative client configuration name source](https://learn.microsoft.com/en-us/azure/event-grid/mqtt-client-authentication)”; doing so would require you to include the Client Name in the certificate you generate for your client connection in the designated property.

For example, given a Client Name of “eventGridDevice001” and selecting “Certificate DNS” as an alternative source field, using `openssl` you could generate a certificate for authenticating against Event Grid with the following command (replacing with your respective values):

```auto
openssl req -nodes -x509 -sha256 -newkey rsa:4096 \
  -keyout example.org.key \
  -out example.org.crt \
  -days 365 \
  -subj "/C=US/ST=Ohio/L=Cincinnati/O=Losant/CN=example.org" \
  -addext "subjectAltName = DNS:eventGridDevice001"

```

---

<div class="post-metadata">

### Author: ![Gambit\_Support](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/gambit_support/32/826_2.png) [@Gambit\_Support](https://forums.losant.com/u/Gambit_Support)
#### Post date: [July 21, 2023, 4:51pm UTC](https://forums.losant.com/t/azure-event-grid-integration/5155/4 "2023-07-21T16:51:22Z")

</div>

We figured out the API workflow node and implemented this.  
2-minute video at

https://www.youtube.com/embed/bS-TznQ4V38?feature=oembed&wmode=opaque&list=PLS47QG_BdOlR-Rpl48ChOxPZk8FM7RumQ
