我有一个简单的 Azure 函数,定义如下:
import logging
import cdsapi
import azure.functions as func
import sys
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function is about to process request.')
try:
cds = cdsapi.Client()
cds.url="urlgoeshere"
cds.key="keygoeshere"
cds.retrieve("reanalysis-era5-pressure-levels",
{
"variable": "temperature",
"pressure_level": "1000",
"product_type": "reanalysis",
"year": "2008",
"month": "01",
"day": "01",
"time": "12:00",
"format": "grib"
},"download.grib")
return func.HttpResponse(
"This HTTP triggered function executed successfully.",
status_code=200
)
except:
logging.info(" error!", sys.exc_info()[0], "occurred.")
我的目的是在命令下检索数据cds.retrieve。当我从 Visual Studio 代码中调试它时,它工作得很好。但是当我通过 VS code 将它部署到 Azure 函数时,它根本不起作用。我收到以下错误:
2020-09-02T16:01:45Z [Information] Executing 'Functions.azure-cds' (Reason='This function was programmatically called via the host APIs.', Id=ae0df178-f726-461e-aca7-8ada6995feaa)
2020-09-02T16:01:45Z [Verbose] Sending invocation id:ae0df178-f726-461e-aca7-8ada6995feaa
2020-09-02T16:01:45Z [Verbose] Posting invocation id:ae0df178-f726-461e-aca7-8ada6995feaa on workerId:e365cae7-bb7c-4f14-92b9-82b5cb77334b
2020-09-02T16:01:45Z [Information] Python HTTP trigger function is about to process request.
2020-09-02T16:01:45Z [Error] Executed 'Functions.azure-cds' (Failed, Id=ae0df178-f726-461e-aca7-8ada6995feaa, Duration=9ms)
在requirements.txt我添加了依赖项:
azure-functions
cdsapi
似乎第 3 方 API 需要在 azure 门户中以某种方式进行调整,感谢解决此问题的任何帮助。
侃侃无极
相关分类