I have Function App of Python v2 and docker based.
function_app.py:
import loggingimport timeimport azure.functions as funcfrom selenium import webdriverimport chromedriver_autoinstallerapp = func.FunctionApp()@app.schedule(schedule="0 * * * * *", 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!') chromedriver_autoinstaller.install() browser = webdriver.Chrome() browser.get('http://selenium.dev/') assert "Selenium" in browser.title time.sleep(5) browser.quit() logging.info('Python timer trigger function executed.')local.settings.json:
{"IsEncrypted": false,"Values": {"AzureWebJobsStorage": "UseDevelopmentStorage=true","FUNCTIONS_WORKER_RUNTIME": "python","AzureWebJobsFeatureFlags": "EnableWorkerIndexing" }}requirements.txt:
azure-functionschromedriver-autoinstallerDockerfile:
FROM mcr.microsoft.com/azure-functions/python:4-python3.11ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=trueCOPY requirements.txt /RUN pip install -r /requirements.txtCOPY . /home/site/wwwrooterror: Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: python not found.
Errors in VS Code:
1st time deployment is successful but I didn't get the timer trigger function in the azure portal.
2nd time deployment:
3:07:49 PM fa-pyv2d-ci-001: Triggering recycle (preview mode disabled).3:07:50 PM fa-pyv2d-ci-001: Deployment successful. deployer = ms-azuretools-vscode deploymentPath = Functions App ZipDeploy. Extract zip. Remote build.3:08:11 PM fa-pyv2d-ci-001: Syncing triggers...3:08:14 PM fa-pyv2d-ci-001: Querying triggers...3:08:19 PM fa-pyv2d-ci-001: No HTTP triggers found.3rd time deployment: - Failed
3:18:51 PM fa-pyv2d-ci-001: Zip package size: 2.83 kB3:18:54 PM fa-pyv2d-ci-001: Fetching changes.3:18:55 PM fa-pyv2d-ci-001: Cleaning up temp folders from previous zip deployments and extracting pushed zip file /tmp/zipdeploy/47acfecb-1a01-482a-a933-8a41bf22c5e4.zip (0.00 MB) to /tmp/zipdeploy/extracted3:19:20 PM fa-pyv2d-ci-001: Deployment failed.
