I have noticed of my Azure Queue has triggered and after 8 minutes the same queue has started again with the same queue message as per my app insight logs.
Where I can find the Azure logs for queue triggered or function have restarted or function has failed? I have read one of those articles Azure dependencies where they have explains dependencies.
Thank you in advance.
If you have configured Diagnostic Settings for your function then you can query the Log analytics workspace ( usign Kusto query) for FunctionAppLogs like below. The field "Message" contains the reason why the fucntion was executed. For e.g if the function was executed via an API call then you would see something like "Reason=This function was programmatically called via the host APIs". You can search for specific words in the message. Also there is a Level field ( like Information, Warning,Error) on which you can filter. Here is the relevant docs from Azure.
FunctionAppLogs
| where Message contains "ServiceBus"
Related
I have an Azure function, which fails while running Startup.cs (while initializing the runtime) because it can't load a key from a Key vault. I would like to automate the deployment of this function in the future and therefore I would like to set up an alert to trigger if the function can't initialize correctly for any reason. (I can fix this speficic error, I just use it as an example).
At the moment I see the error in the Notifications section of the function page in the Azure portal:
I also see the exceptions in Diagnose and solve problems -> Availability and Performance:
But I can't seem to find a way to set up an alert to respond to this situation. I assumed that Resource health alert would cover this, but it doesn't. Maybe because to portal reports the function as Status: Running. I also can't find this error in Application Insights.
Is there any way to set up this alert?
To create the Alerts for Function App Runtime failures, start with the Alert Action Groups.
Open your function app in the Azure Portal and create the action group that points to your function and email configuration:
In the same function app menu > Logs > Get the Function Request Failure results such as below:
Then, click on “New Alert Rule” > Insert the values for Alert logic such as Frequency of Evaluation, Operator, Threshold Value, Measure of data summary, etc.,
Next, Select the Action Group which is created at the starting - that contains the Selected Function Data and the Email Notification configuration details:
After configuring the alert group, you’ll get the mail that the alerts are mailed accordingly:
I have given the wrong input to get the alert for the Function Runtime failure, which is driven to the Alerts:
Result:
For more details regarding Azure Alerts, refer to this MS Doc.
Updated Answer:
- This query gives the function errors messages in the logs and from this panel we can create the alert rule for the errors and warnings.
How do you view the context.log messages for an Azure Node.js Function?
If I have the following:
exports.handler = async (context) => {
context.log.info('Hello Bob');
};
Where would I go to see Hello Bob?
I know exactly how to view such a phrase in AWS Cloudwatch but I cannot find the same in Azure. I have looked at: https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitoring but it points to Application Insights which when I go there and look at say, Activity Logs, there is no information. I have also looked at Logs on that screen but it wants to run queries. So, how do you look at context.log.info data within Azure?
You can access that in the Azure Portal
It does not appear immediately. may take a couple of minutes after you run your function. also make sure the function has started
Locate your Function app and click "Functions" > "your function name" > "Monitor" and any of the log records:
Or you can use the insights for that:
and
I have an Azure infrastructure:
2 HTTP Functions -> Event Hub -> 2 Functions -> Table Storage
(so two http functions sending messages to event hub, and two functions triggered by messages in Event Hub, one of them saving message in table storage)
The infrastructure is daily automatically created by Azure ARM templates, with the use of Azure CLI. I haven't changed the logic in recent two months but since beginning of April I have noticed the new, weird behaviour.
At the end of setting up, E2E tests are executed automatically. They are sending some message and after some time they check, if message are in table storage.
And here is the problem: since beginning of April these tests almost always fail! And I did not change anything in logic of function or template.json's for infrastructure.
It looks that Functions that should be triggered by Event Hub are not executed at all! I have already found a workaround for it - if I go to Azure portal and run these functions manually ("Run" button above code editor), then the functions finally starts to work!
Does anybody else encounter this problem?
Is there some way to automatically, directly run non-HTTP triggered function by e.g. Azure CLI or REST interface?
It seems that problem is already quite well known:
https://github.com/Azure/Azure-Functions/issues/210
I'm using currently workaround from this issue, i.e. calling Azure CLI's method to synchronize function triggers after creating infrastructure and zip pushing of functions:
az resource invoke-action --resource-group <resourceGrouName> --action syncfunctiontriggers --name <functionAppName> --resource-type Microsoft.Web/sites
I'm trying to set up an Azure Function that I want to trigger when a message is put on a Service Bus queue. However, I can´t get it to work. The first "log.Info" does not trigger.
I deployed an Http trigger together with my Service Bus trigger and that works.
Some screenshots is shown below. I´ve already tried to remove the json string with key "generatedBy", as I saw as a suggestion on Google.
There are two files in my Visual Studio project which I have not edited: host.json and local.settings.json, I can´t find information about how to set them up or if it´s necessary at all.
Can anyone help me?
The Connection property of ServiceBusTrigger attribute should refer to a setting name, e.g. ServiceBusConnectionString.
Then, you should put the setting with same name to local.settings.json for local development and to Application settings for Azure.
I needed to append this bit to my ServiceBusConnectionString when running locally:
;TransportType=AmqpWebSockets
For some reason, I'm unable to make the connection from Stream Analytics to my Azure Function as an output. I have this exact pipeline set up and working in my own Azure subscription, but can't get this output connection to work in my dev environment.
Unable to load subscriptions PIC
First, the drop-down does not load the available function apps and functions in the subscription, as seen above. There are multiple that are in the subscription and are running, so this should populate. Instead, I see the error "Failed to load function apps" and "Failed to load functions."
Second, when I try to fill in the fields manually (after selecting "Provide azure function settings manually") I am also unable to connect. To do this, I'm giving the output a unique name, then copy/pasting the function app name and function name to the blanks. For the key, I've tried many variations to no avail. My function currently has Authorization set to anonymous, and I've tried leaving the key field blank. I've also tried using the "Function" key on my function, as well as the _master and default access keys. Each give me an error message when testing output connection. How do I get this connected?
Manual function setup PIC
Here is the error that I get
Error PIC
UPDATE - I'm still working on this, but at least part of it was due to having a hyphen "-" in the function name. Apparently Azure doesn't like that. Once I fixed the function name I'm able to trigger the function manually from within the Azure portal and externally through Postman, but still the connection test is failing from Stream Analytics.
UPDATE 2 - My temporary work around has been to have Stream Analytics post its output to an Event Hub, and trigger a function off of the Event Hub's traffic.