all Technical posts

Logic Apps and EDI – AS2 and MDN Failures

Azure Logic apps and the Enterprise Integration account provide a mechanism for implementing business to business (B2B) solutions. This blog will outline the way these resources were used in a recent project and highlight some MDN issues that had to be resolved.


The project had to receive and send EDI messages (EDIFACT) from/to partners using the AS2 protocol. It used a publish-subscribe architecture built on our framework which handles all the message routing and monitoring of the message flow via a dashboard.


Each inbound AS2 message had to be signed and encrypted by the partner and an asynchronous Message Disposition Notification (MDN) returned. To enable this, the following was added to the integration account:

  1. A Trading Partner was created for each partner.
  2. An AS2 Trading Partner Agreement was created between the customer and each partner.
  3. Each partner’s public certificate which was used for message signature validation.
  4. The customer’s private key which was used for decryption. This key also needs to be added to an Azure Key Vault.

MDN settings can be found in the agreement in both the Receive and Send sections:

Logic Apps and EDI – AS2 and MDN failures

For inbound messages, a publish logic was created and actions were added to decode the AS2 message, determine if a MDN is required and if so, send it asynchronously or synchronously:

Logic Apps and EDI – AS2 and MDN failures

Finally, the message was decoded using the Decode EDIFACT action, transformed using an XLST map in the integration account before being sent to Oracle NetSuite via an Azure Function:

Logic Apps and EDI – AS2 and MDN failures

For outbound messages, these were first transformed using an XSLT map before being encoded to EDIFACT and then encoded using the AS2 Encode action:

Logic Apps and EDI – AS2 and MDN failures

Inbound MDN failures

One issue was with inbound messages that occurred when sending the MDN back asynchronously. It would fail on the partner’s end. After some investigation it was found this was because of the Logic app headers that are returned in the response. The solution was to add a policy to the APIM operation to remove the following headers:

Logic Apps and EDI – AS2 and MDN failures

Outbound MDN failures

For outbound, the issue occurred when the encrypted AS2 message was sent to the partner. They were seeing a decryption error. After investigation it was found that the message needed to be converted from a base64-encoded string to application/octet-stream using the base64ToBinary converter function:

Once this was added, the messages were processed successfully and an MDN sent back from the partner.

I hope this blog has given some insight into how logic apps can be used in an EDI solution as well as to highlight some of the MDN issues that might be encountered.


Subscribe to our RSS feed

Thanks, we've sent the link to your inbox

Invalid email address


Your download should start shortly!

Stay in Touch - Subscribe to Our Newsletter

Keep up to date with industry trends, events and the latest customer stories

Invalid email address


Great you’re on the list!