我有一个用Python 3.11.9在Visual Studio代码中编写的时间触发函数。该函数在本地成功运行(使用 F5)。当我从 Visual Studio Code 将该函数部署到 Azure 门户时,它显示为“部署成功”。在“输出”和“Azure”选项卡中
但是,当我转到 Azure 门户上的功能应用程序时,应用程序文件显示在功能部分中
但是我的时间触发函数没有显示在Azure门户中函数应用程序的概述部分中
从 VS Code 部署时,我尝试从以下位置部署:
(输出略有不同,见下文)
但是这些方法都无法解决 Azure Function 未显示在我的 Azure Portal Function App 上的问题。
这是带有导入的函数代码(function_app.py)
import logging
import azure.functions as func
import requests
import json
from simple_salesforce import Salesforce
import pandas as pd
import csv
from flatten_json import flatten
#for extending csv file for 1 day at a time holidays
import datetime as dt
from datetime import timedelta
from urllib.parse import urlparse, urljoin
#used to save to specific folder
import os
from dotenv import load_dotenv
from shareplum import Site
from shareplum import Office365
from shareplum.site import Version
from io import BytesIO
from io import StringIO
import pandas as pd
from office365.runtime.auth.authentication_context import AuthenticationContext
from io import BytesIO
from office365.runtime.auth.client_credential import ClientCredential
from office365.sharepoint.client_context import ClientContext
#sharepoint
# import necessary modules
from shareplum import Site
import pandas as pd
from shareplum import Office365
from shareplum import Site
from shareplum.site import Version
import pandas as pd
import numpy as np
from sklearn.datasets import load_iris
from IPython.display import display
from tabulate import tabulate
from pandas import json_normalize
from office365.sharepoint.files.file import File
import pandas as pd
import io
import errno
from datetime import datetime, timedelta
from pathlib import Path
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from azure.core.exceptions import ResourceNotFoundError
from azure.storage.blob import BlobServiceClient
from azure.identity import DefaultAzureCredential
from azure.keyvault.keys import KeyClient
app = func.FunctionApp()
@app.schedule(schedule="0 */5 * * * *", arg_name="myTimer", run_on_startup=True,
use_monitor=False)
def timer_trigger(myTimer: func.TimerRequest) -> None:
if myTimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function executed.')
#full script below this, inline with function so it runs when the function runs
使用的模块(requirements.txt文件)
flatten-json==0.1.14
ipython==8.12.3
numpy==1.26.4
Office365-REST-Python-Client==2.5.7
pandas==2.2.0
python-dotenv==1.0.1
requests==2.31.0
scikit-learn==1.4.2
SharePlum==0.5.1
simple-salesforce==1.12.5
tabulate==0.9.0
local.settings.json 文件(我尝试使用“UseDevelopmentStorage=true”而不使用此文件,两者都给出了相同的结果,Azure 门户上不存在任何功能)
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
}
}
请添加
requirements.txt
文件中的所有模块。我在 requirements.txt
中添加了以下模块,这些模块在 function_app.py
中使用。
azure-functions
requests
simple-salesforce
pandas
flatten-json
python-dotenv
SharePlum
Office365-REST-Python-Client
numpy
ipython
scikit-learn
tabulate
azure-identity
azure-keyvault
azure-core
azure-storage-blob
我在
function_app.py
文件中有与你相同的代码。