Python 从谷歌云函数触发DAG

Python 从谷歌云函数触发DAG,python,google-cloud-platform,google-cloud-functions,google-cloud-storage,google-cloud-composer,Python,Google Cloud Platform,Google Cloud Functions,Google Cloud Storage,Google Cloud Composer,我一直在尝试在文件到达基于Python中Cloud with Cloud函数的GCS存储桶时,在Cloud Composer中执行DAG(Composer-1.8.1-airflow-1.10.3) 我无法使它工作,每次它触发时,函数都会将此消息返回到日志 Exception: Bad response from application: 400 / {'Date': 'Mon, 30 Dec 2019 18:07:02 GMT', 'Content-Type': 'text/html', 'C

我一直在尝试在文件到达基于Python中Cloud with Cloud函数的GCS存储桶时,在Cloud Composer中执行DAG(Composer-1.8.1-airflow-1.10.3

我无法使它工作,每次它触发时,函数都会将此消息返回到日志

Exception: Bad response from application: 400 / {'Date': 'Mon, 30 Dec 2019 18:07:02 GMT', 'Content-Type': 'text/html', 'Content-Length': '192', 'Server': 'gunicorn/19.9.0', 'Via': '1.1 google', 'Alt-Svc': 'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000'} / '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>400 Bad Request</title>\n<h1>Bad Request</h1>\n<p>The browser (or proxy) sent a request that this server could not understand.</p>\n'
感谢

初始问题中反映的错误代码通常与客户端问题相对应,事实上,应该首先检查DAG触发的输入参数,调用代码中调用的函数:

确保通过
requirements.txt
文件应用了运行IAP保护URL所需的依赖项

不要忘记验证传递给此函数的基本参数:

url:要获取的标识感知代理保护的url

客户端id:身份感知代理使用的客户端id


到目前为止,我还没有找到更好的触发DAG的亲身体验,他在他的著作中解释道。

谢谢,我解决了我的问题,
requests.request(方法,url,headers={'Authorization':'Bearer{}.format(google_open_id_connect_token)},**kwargs)
“生成iap请求”功能的。我不需要任何参数来调用气流,所以我没有使用任何kwarg。看来调用函数需要JSON参数
resp = requests.request(
    method, url,
    headers={'Authorization': 'Bearer {}'.format(
        google_open_id_connect_token)}, **kwargs)
if resp.status_code == 403:
    raise Exception('Service account {} does not have permission to '
                    'access the IAP-protected application.'.format(
                        signer_email))
elif resp.status_code != 200:
    raise Exception(
        'Bad response from application: {!r} / {!r} / {!r}'.format(
            resp.status_code, resp.headers, resp.text))
def make_iap_request(url, client_id, method='GET', **kwargs)