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.
Related
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"
I created alert rule in log analytics,and then i exported template to create another alert rule automatically
I need to create alert rule automatically exactly same as manually created alert rule
I am able to create alert rule with the exported template,but the alert rule condition which is created by template is different from alert rule which is created manually in the portal
as shown in below diagrams:
Let me know if any additional information required
Thanks in advance
The screenshots in your question are of the alert Condition names, Azure derives these from the properties of the alert condition. The Condition names can't be set explicitly when creating an alert in the Azure Portal or via an ARM template. Unfortunately it seems that Azure Resource Manager produces slightly inconsistent Condition names depending on whether the alert is created in the Azure Portal or via an ARM template.
As long as the ARM template wasn't modified you should see that the alert condition properties are the same, you can inspect these by clicking on the Whenever the average custom log search is greater than or equal to 1 or Whenever the Count of the Custom log search is greater than or equal to 1 links, that should bring up the Configure signal logic blade.
I would like to set up an Azure alert for when someone on our team sets up an Azure database. Once alerted, I want to have an additional alert created if that resource is running for more than a certain amount of time.
My solution is to create an Alert Rule on the storage account and have it send an email. Where I'm running into trouble is how to monitor the database, since it just got created and I don't know the name yet for the second Alert rule that will monitor its uptime.
Is there some programmatic way to determine the database resource name?
If you don't want to invest time in Programmatic way there is a option to set or configure an alert at Resource Group level based on Resource type, where in the alert rule configure with below configurations
Scope -Select the right subscription, filter by resource type like SqlDatabase and if required filter based on location wise
Condition - In Select condition, Signal type drop down select "Create/Update Azure Sql Database" and in alert logic you can provide additional filtering logic's
Can choose existing Action group or create new one based on your requirement
Add "Alert rule details" like rule name, description etc.
Finally create alert rule
Now once alert rule is created if any new Azure SqlDatabase is created you will be notified based on alert configured.
According to the official doc, you can use Event Grid to notify Azure Automation when a SQL database is created.
https://learn.microsoft.com/en-au/azure/event-grid/overview#ops-automation
Once you subscribe, you can use Logic Apps to send you an email for example.
About the second part, you'll need to query the metrics and figure out if it's running (is performing compute) or not.
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.
I have an Azure WebJob and when it picks up a message from the queue I get the error
"Function had errors. See Azure WebJobs SDK dashboard for details".
The dashboard shows no errors, it just insists my connection strings are not set which they are or else it wouldn't pick up the message.
When debugging locally how can I find out what the actual error is?
You can debug locally by explicitly setting the Dashboard connection string to null in the JobHostConfiguration object. That will make the host show all errors in the console rather than dashboard.
What connection strings do you set (their names)?