将动态文件路径从 Azure Databricks 代码发送到用于电子邮件附件的 Azure 逻辑应用程序

问题描述

嗨,我是逻辑应用程序的新手。我有一个 python 代码,用于使用 Azure 逻辑应用程序发送带有附件的邮件。当我在获取 Blob 内容中提供静态文件路径时,邮件与附件一起工作正常。但是,当我尝试从 azure databricks 动态发送文件路径时,它没有在逻辑应用程序中的 get blob 内容中接收。我也尝试了一些使用初始化变量的例子,但它不起作用。

import requests

def send_email(_to,_subject,_body,file):
  
  email_body = "{0} <br><br><br> <h6> Hi Hello World </h6>".format(_body)
  
  task = { "body_data_1": email_body,"subject_name_1": _subject,"email_to_list_1": _to,"attach" : file }
  logic_app_post_url = 'https://prod-27.centralindia.logic.azure.com:443/workflows/*****'
  resp = requests.post(logic_app_post_url,json=task)
  print(resp.status_code)
  if resp.status_code == 202:
    print('Email Sent!')

email_to = "abc@outlook.com"
email_subject = "Testing Logic App Send Mail with Dynamic File"
email_body = "Hi This is a test mail Dynamic"
file_path = "/super-store/output/orders/_SUCCESS"
send_email(email_to,email_subject,email_body,file_path)

逻辑应用设计

enter image description here

逻辑应用运行错误详情

enter image description here

HTTP 输入

enter image description here

HTTP 输出

enter image description here

获取 Blob 内容输入

enter image description here

获取 Blob 内容输出

enter image description here

解决方法

我们观察到 Get Blob Content (V2) 被用于从 azure 数据块动态发送附件。相反,我们建议使用使用 Path(V2) 连接器获取 Blob 内容。

其中Get Blob Content (V2)连接器将检索使用id的blob内容,而Get Blob Content using Path (V2)连接器检索blob内容使用路径

片段示例:

enter image description here enter image description here

结果:

enter image description here