最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure function app python - Encountered an error (InternalServerError) from host runtime - Stack Overflow

programmeradmin0浏览0评论

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=/;LiveEndpoint=/;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": "/",
    "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!")

Configurations:

Any pointers how to trouble shoot this?

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/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure/;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/",
    "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!")

Configurations:

Any pointers how to trouble shoot this?

Share Improve this question asked Jan 30 at 15:43 Thomas SegatoThomas Segato 5,27516 gold badges64 silver badges131 bronze badges 1
  • In Invocations, you can the complete logs – RithwikBojja Commented Jan 31 at 3:31
Add a comment  | 

1 Answer 1

Reset to default 0

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/;LiveEndpoint=https://canadacentral.livediagnostics.monitor.azure/;ApplicationId=9ab8rithwik815c",
    "slotSetting": false
  },
  {
    "name": "AzureWebJobsStorage",
    "value": "DefaultEndpointsProtocol=https;AccountName=rithwik8980;AccountKey=8d7arithwik+AStQO4/dw==;EndpointSuffix=core.windows",
    "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",
    "slotSetting": false
  },
  {
    "name": "WEBSITE_CONTENTSHARE",
    "value": "rithapp099af2",
    "slotSetting": false
  }
]

General Settings:

Output:

Invocations:

发布评论

评论列表(0)

  1. 暂无评论