Hi Dan,
I think the issue resides in what you are trying to log. Your logging configuration for the file system is set to "Error" level. If your timer-triggered function is producing logs at a level other than "Error" (like "Information", "Verbose", or "Warning"), those logs won't be saved in the file system and subsequently won't be downloaded with the az webapp log download
command.
I recommend starting with the above as its the simplest way.
Also, Sometimes, logs visible in the Azure portal (especially through the monitor blade) are stored in a different location than those accessed via the az webapp log download
command. The command is designed to download logs from the file system, but the portal may also display logs stored in other services like Application Insights. Ensure that your function's logs aren't being stored or streamed to a different location.
this is a bit complex to determine, however, here is how you can do it:
Identify the Storage Location:
- Open the Azure portal & Navigate to your Azure Function.
- Under the Monitoring section, click on "Diagnostic settings" or "Diagnostic logs". This should show you where your logs are being sent to. Common destinations include Application Insights, Azure Blob Storage, Azure Monitor Logs, etc.
Access Logs in Application Insights:
- If your logs are stored in Application Insights:
- Navigate to the Application Insights instance associated with your Function App.
- Use the "Search" or "Logs" section to query and view your logs.
- For programmatic access or for downloading the logs, you can use the Application Insights REST API.
Access Logs in Azure Blob Storage:
- If your logs are being sent to Azure Blob Storage:
- Navigate to the Storage Account and find the Blob container where logs are stored.
- Use Azure Storage Explorer, Azure portal, or Azure CLI to download the log blobs.
- For instance, to download blobs using Azure CLI:
- Use Azure Storage Explorer, Azure portal, or Azure CLI to download the log blobs.
- Navigate to the Storage Account and find the Blob container where logs are stored.
az storage blob download --container-name your-container-name --name your-blob-name --file destination-file-path --account-name your-storage-account-name
Azure Monitor Logs (Log Analytics):
- If your logs are stored in Azure Monitor Logs:
- Navigate to the Log Analytics workspace where your logs are stored.
- Use the Kusto Query Language (KQL) to query your logs.
- There is no direct Azure CLI command to download logs from Log Analytics as of my last update in September 2021. However, you can use the Azure REST API or PowerShell to programmatically retrieve logs.
Adjust Diagnostic Settings:
- If you wish for your logs to also be stored in the file system for easy access via
az webapp log download
:- Navigate to the Azure Function's Diagnostic settings.
- Adjust the destination to include Filesystem, ensuring that the correct log level and category are set.
- Navigate to the Azure Function's Diagnostic settings.
More information: https://learn.microsoft.com/en-us/azure/azure-monitor/data-sources
I hope this helps, if you where able to resolve your issue please mark this as your answer., and consider following.