In Azure Data Factory using "base64(string)" expression unable to get PDF file content from blob and send file as attachment

Arundhati Sen 151 Reputation points
2023-08-17T17:18:23.3566667+00:00

dummy.pdfI am trying to read a pdf file from blob using web activity and the response I am sending as attachement using sendgrid with another web activity.

  1. Using a web activity I am getting the file content in Response
    User's image
  2. Then getting the output and encoding it using @base64()

User's image

  1. Then using sendgrid api to send mail. Using sendgrid key for authorization.

User's image

{
	"personalizations": [
		{
			"to": [
				{
					"email": "******@gmail.com"
				},
			],
			"subject": "send attachment from ADF"
		}
	],
	"from": {
		"email": "******@gmail.com"
	},
	"content": [
		{
			"type": "text/html",
			"value": "test"
		}
	],
	"attachments": [
		{
			"content": "@base64(string(activity('Web Get Blob File data').output.Response))",
			"filename": "@{item().name}"
		}
	]
}

This process is working file for xml file, and correct xml is getting sent. But for PDF I am getting blank PDF in mail attachment.
Attached dummy PDF file for reference
Also using LogicApps I am able to send PDF, but in our project ADF is the required to be used.

Please help!!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2023-08-18T05:10:48.55+00:00

    Hi Arundhati Sen,

    Thank you for posting query in Microsoft Q&A Platform.

    One possible reason for this issue is that the PDF file is not being read correctly from the blob storage. PDF files are binary files, and they need to be read in binary mode to ensure that the contents are not corrupted. You can try adding the responseType parameter to the web activity to ensure that the file is read in binary mode.

    Or

    As you mentioned using logic app you were able to do. consider having your logic app trigger type as HTTP trigger and then make API call to logic app. We can do this using web activity in azure data factory.

    Hope this helps. Please let me know if any further queries.


    Please consider hitting Accept Answer button. Accepted answers helps community as well.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.