I have created a very simple azure function in python but keep getting folowing error when trying to run it. I cant find anything in app insights:
Environment variables:
[
{
"name": "APPINSIGHTS_PROFILERFEATURE_VERSION",
"value": "1.0.0",
"slotSetting": false
},
{
"name": "APPINSIGHTS_SNAPSHOTFEATURE_VERSION",
"value": "1.0.0",
"slotSetting": false
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "InstrumentationKey=xx-xx-xx-xx-f435e1b90ad8;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=xx-xx-xx-xx-xx",
"slotSetting": false
},
{
"name": "ApplicationInsightsAgent_EXTENSION_VERSION",
"value": "~3",
"slotSetting": false
},
{
"name": "AzureWebJobsStorage__accountName",
"value": "stdnaexchangeratesdev",
"slotSetting": false
},
{
"name": "AzureWebJobsStorage__blobServiceUri",
"value": "https://xx.blob.core.windows.net/",
"slotSetting": false
},
{
"name": "BUILD_FLAGS",
"value": "UseExpressBuild",
"slotSetting": false
},
{
"name": "ENABLE_ORYX_BUILD",
"value": "true",
"slotSetting": false
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4",
"slotSetting": false
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "python",
"slotSetting": false
},
{
"name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
"value": "1",
"slotSetting": false
},
{
"name": "WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED",
"value": "1",
"slotSetting": false
},
{
"name": "XDG_CACHE_HOME",
"value": "/tmp/.cache",
"slotSetting": false
},
{
"name": "XDT_MicrosoftApplicationInsights_Mode",
"value": "recommended",
"slotSetting": false
}
]
Code:
import azure.functions as func
import datetime
import logging
import requests
app = func.FunctionApp()
@app.timer_trigger(schedule="0 * * * * *", arg_name="myTimer", run_on_startup=True,
use_monitor=False)
def timer_trigger(myTimer: func.TimerRequest) -> None:
if myTimer.past_due:
print('The timer is past due!')
print("Hello, World!")
Any pointers how to trouble shoot this?
Below code and settings worked for me:
function_app.py:
import logging as rilg
import azure.functions as func
rithapp = func.FunctionApp()
@rithapp.function_name(name="mytimer")
@rithapp.schedule(schedule="0 */1 * * * *", arg_name="mytimer", run_on_startup=True,
use_monitor=False)
def test_function(mytimer: func.TimerRequest) -> None:
rilg.info("Hola")
print("Hello Rithwik!")
requirements.txt:
azure-functions
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
}
}
Then deployed to Azure.
App Settings in Environment Variables Section:
[
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "InstrumentationKey=0d7rithwik0efc1;IngestionEndpoint=https://canadacentral-1.in.applicationinsights.azure.com/;LiveEndpoint=https://canadacentral.livediagnostics.monitor.azure.com/;ApplicationId=9ab8rithwik815c",
"slotSetting": false
},
{
"name": "AzureWebJobsStorage",
"value": "DefaultEndpointsProtocol=https;AccountName=rithwik8980;AccountKey=8d7arithwik+AStQO4/dw==;EndpointSuffix=core.windows.net",
"slotSetting": false
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4",
"slotSetting": false
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "python",
"slotSetting": false
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "DefaultEndpointsProtocol=https;AccountName=rithwik8980;AccountKey=8d7rithwiks+AStQO4/dw==;EndpointSuffix=core.windows.net",
"slotSetting": false
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "rithapp099af2",
"slotSetting": false
}
]
General Settings:
Output:
Invocations: