【问题标题】:Timer Trigger in Azure function is not working when i do Code+test当我执行代码+测试时,Azure 函数中的计时器触发器不起作用
【发布时间】:2020-12-04 01:20:25
【问题描述】:

我在我的 Visual Studio 中的 Azure 函数中创建了一个计时器触发器,如下所示,并将其部署在 Azure 门户中。一旦我尝试执行代码+测试,它就会给我输出为 HTTP 响应代码:202 Accepted HTTP响应内容(显示为空白)

__init__.py 

import os
import json
import logging
import requests
import numpy as np
import pandas as pd
import azure.functions as func
import azure.storage.blob
from azure.storage.blob import BlockBlobService

def main(mytimer: func.TimerRequest) -> None:
    utc_timestamp = datetime.datetime.utcnow().replace(
        tzinfo=datetime.timezone.utc).isoformat()

    if mytimer.past_due:
        logging.info('The timer is past due!')
    logging.info('Python timer trigger function ran at %s', utc_timestamp)

execute_timer() # This function is business logic and basically it saves CSV file in a container BLOB.

function.json

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "mytimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 * * * * *"
    }
  ]
}

当我部署并运行它时。它给了我 202 被接受,但我看不到我的输出生成或它被安排。

谁能帮我解决这个问题。

【问题讨论】:

    标签: python azure-functions timer-trigger


    【解决方案1】:

    要查看输出信息,您需要连接窗口下的日志。

    点击 Logs 后,等待一分钟连接和记录,你会看到这个。

    【讨论】:

    • 您好 Doris Lv,感谢您的回答。我能够看到日志,但我无法导航到我定义的逻辑,即 execute_timer(),它说执行失败。另外,我需要在 function.json 文件中添加任何内容吗?
    • 您不需要在 function.json 文件中添加任何内容。关于您的 i.e.execute_timer(),您能否发布详细信息?@umad44
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-12
    • 1970-01-01
    • 1970-01-01
    • 2020-11-06
    相关资源
    最近更新 更多