I am working on Azure Function App (Python on Linux), but I am unable to view the logs.
When I go to web portal to the Function App - tab Log Stream, the page never loads. There is just a spinning circle.
The same happens when I open the Function itself and go to "Code + Test". The console says, Connecting to Application Insights...
, but it never loads.
The Function App is not linked to "Application Insights". But to my understanding I do not need to create Application Insights resource to just see simple logs. Or am I wrong?
I am quite new to Azure, so I appreciate any help!
In this post one of the users says that log streaming has been limited, so I assume that I am facing the similar issue. I have tried using VS Code extension Azure to stream logs, but it also requires Application Insights. Error: You must configure Application Insights to stream logs on Linux Function Apps
.
Do I really have to create Application Insights resource? (It's complicated for me to create new resource due to corporate structure)
Edit:
As requested I am adding the code. I don't think that the issue is with the code itself. I am unable to view any logging page in Azure web portal as well as I am unable to stream logs to VS Code. The issues occurs even before running the code.
I am expecting to see at least something. Any print or log statement, or even error message. But I am unable to anything.
Also here here are some screenshots from Azure Portal and the issues I am facing.
""" function_app.py """
import azure.functions as func
import logging
@app.route(route="http_trigger_test")
def http_trigger_test(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
return func.HttpResponse(f"Code finished", status_code=200)
""" requirements.txt """
# DO NOT include azure-functions-worker in this file
# The Python Worker is managed by Azure Functions platform
# Manually managing azure-functions-worker may cause unexpected issues
azure-functions
""" http_trigger_test.json """
{
"name": "http_trigger_test",
"entryPoint": "http_trigger_test",
"scriptFile": "function_app.py",
"language": "python",
"functionDirectory": "/home/site/wwwroot",
"bindings": [
{
"direction": "IN",
"type": "httpTrigger",
"name": "req",
"authLevel": "ANONYMOUS",
"route": "http_trigger_test"
},
{
"direction": "OUT",
"type": "http",
"name": "$return"
}
]
}
The Function App is not linked to "Application Insights". But to my understanding I do not need to create Application Insights resource to just see simple logs. Or am I wrong?
For getting simple logs or complex logs will definitely use application insights, there is no other option to get logs. Refer this SO for further clarification.
I have created http trigger function by using vs code and it ran successfully.
I have deployed the above function into azure portal. check below:
Before enable the application insights, when I tried to visit logs getting like below:
I was enabled the application insights and rans the function successfully in portal. check below:
I was able to see the logs after enabled the application insights. check below:
Output: