Hello Paul, To view logging data for your Python-based Azure Functions in the Azure Portal, similar to what you see in VSCode, use Application Insights. Here’s how to set it up:
- Enable Application Insights for Your Function App
Go to your Function App in the Azure Portal > Under Settings, select Application Insights > Click on Enable if it’s not already enabled, and link your Function App to an Application Insights instance. If you don’t have an instance, Azure will prompt you to create one. - Configure Logging in Your Python Code
Make sure to use thelogging
module in your function code, as shown in your screenshot. Application Insights automatically captures logs created bylogging.info
,logging.error
, etc.import logging @app.function_name(name="BlobTriggerFunction") @app.blob_trigger(arg_name="myblob", path="raw/files/{name}.csv", connection="DEPLOYMENT_STORAGE_CONNECTION_STRING__accountname") def BlobTrigger(myblob: func.InputStream, context: func.Context): logging.info("Python blob trigger function processed blob") logging.info(f"Name: {myblob.name}") logging.info(f"Blob Size: {myblob.length} bytes")
- View Logs in Application Insights
Go to Application Insights linked to your Function App > Navigate to Logs under Monitoring > Use the following Log Analytics Query to see your logs:
Replacetraces | where customDimensions["Category"] == "Function.<YourFunctionName>" | order by timestamp desc
<YourFunctionName>
with the actual function name (e.g.,BlobTriggerFunction
). - Use Live Metrics for Real-Time Monitoring
In Application Insights, go to Live Metrics to see real-time logs and metrics. - Alternative: Log Streaming with App Service Logs (Premium Plans)
If your Function App is on a Premium Plan, you can enable App Service Logs for log streaming.
Go to Monitoring > App Service Logs > Enable Application Logging (Filesystem) and set the log level > Use Log Stream to view logs in near real-time. - For more details:
- Azure Functions Monitoring with Application Insights
If the information helped address your question, please Accept the answer.
Luis