Azure function - Python - Detail logging (Stream)

Bhanuprasad 121 Reputation points
2022-01-22T01:45:04.597+00:00

Azure Function - ~3 with Python

I would like to capture detail log out of SFTP connection from azure function, how can we achieve this?

PySFTP : pysftp.html
pysftp.Connection(host, username=None, private_key=None, password=None, port=22, private_key_pass=None, ciphers=None, log=False)

--From Documentation--

log (bool|str) – Default: False - log connection/handshake details? If set to True, pysftp creates a temporary file and logs to that. If set to a valid path and filename, pysftp logs to that. The name of the logfile can be found at .logfile

We are able to connect to SFTP and able to get the function working successfully, when we have log=True we need to detail logging when the application fails, could you please advise how we can get the detail log to our log analytics

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,559 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-01-24T06:52:10.133+00:00

    @Bhanuprasad ,

    Thanks for reaching out to Q&A.

    Azure Functions offers built-in integration with Azure Application Insights to monitor functions : https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitoring

    You can log information to App insights and then view the detailed logs in Log analytics workspace using Kusto queries. To be specific, the "Traces" , "FunctionappLogs" and "requests" table would give you more detailed logs.

    Python Functions with App insights : https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=azurecli-linux%2Capplication-level#logging

    Live stream : https://learn.microsoft.com/en-us/azure/azure-functions/streaming-logs#live-metrics-stream

    Querying Logs: https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitor-log-analytics?tabs=python#querying-the-logs

    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.