python-3.x - 尽管被禁用,Azure Function 仍在继续执行

标签 python-3.x azure azure-functions

就像标题所说,我有一个 Azure 函数“weekly_monitoring”,它设置为每周执行多个 python 脚本。尽管被禁用,它仍在继续执行。此外,它连续执行多次。我不知道这是怎么可能的,因为我已经通过 UI 以及触发器(cron 计时器)禁用了该功能。另外,当我查看 Azure 函数监视器时,它显示执行事件为零。

这是初始化文件代码:

import azure.functions as func
import os
import datetime
import logging
import sys
import importlib.util

# Azure function timer. To alter timer cadence see function.json file
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)


def run_script(script_name):
    script_path = os.path.join(os.path.dirname(__file__), f'{script_name}')

    s = importlib.util.spec_from_file_location(script_name, script_path)
    m = importlib.util.module_from_spec(s)
    sys.modules[s.name] = m
    s.loader.exec_module(m)

    
def batch_execution(file_list):

     exceptions = [] #store errors

     for file in file_list:
         try:
             run_script(file)
         except Exception as e:
             exceptions.append(e)
         else: 
             print('Success')

     return exceptions

# list of scripts running in function, if adding new script add to list.
 file_list = ['file_one.py',
         'file_two.py',
         'file_three.py',
         'file_four.py',
         'file_five.py']

batch_execution(file_list)

下面是触发函数的代码:

{
    "scriptFile": "__init__.py",
    "bindings": [
      {
        "name": "mytimer",
        "type": "timerTrigger",
        "useMonitor": true,
        "runOnStartup": false,
        "direction": "in",
        "schedule": "0 5 * * MON"
      }
    ],
    "disabled": true
  }

screen shot of the disables function in the Azure UI

Number of functions invocations according to Azure Monitor, I have the script has executed 5 times today

最佳答案

正如在 OP 的评论中发现的那样,之前执行 Azure 函数(预禁用)生成的消息似乎被困在中间电子邮件提供商中,并在死后传递。

关于python-3.x - 尽管被禁用,Azure Function 仍在继续执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76949059/

相关文章:

Python 平方函数

python - 在 Pandas 的坐标行中只保留最大间隔

php - 如何在PHP中的Microsoft Windows Azure代码中存储视频

azure - 如何高效读取数据湖文件的元数据

azure - 为什么 .NET 6 上的 Azure Function 寻找 System.ComponentModel 版本 6.0.0.0?

Azure Functions - 返回没有输出绑定(bind)的值?这可能吗?

azure - 获取队列触发器 azure webjob 的消息元数据

python-3.x - 更改 tempfile.NamedTemporaryFile 的字符集

python-3.x - 根据条件求和值,如果不匹配则保留当前值

json - 使用 Powershell 部署 Azure 策略