I'm using Azure Alerts to use webhooks. I added the webhook in the action group. The URL I used is the one from Slack.
I also added a Notification Type Email. The notification email gets triggered but I am not receiving any message in the Slack channel.
I was able to push messages to the webhooks using postman hence I know my webhook is correct. But Azure Alert is not able to trigger the webhook. I am not receiving any messages in the Slack channel.
Azure Monitor sends a notification with its own schema definition. Slack doesn't recognize it, so you cannot see any notifications in the channel. It is possible to create a Logic App or Azure Function to transform the default schema.
Here the more information about it:
https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-common-schema
Slack expect a json object when using webhooks. When sending directly from azure alert you will get bad request.
Every slack channel has an e-mail adress. You can post messages to the channel using that email in azure alerts
Anyone looking for using Slack and Azure Alerts. This seems to work fine:
...
webhook_receiver {
name = "Slack"
service_uri = "https://hooks.slack.com/services/secret"
use_common_alert_schema = false
}
Then in the scheduled query rules alert:
...
action {
action_group = [data.azurerm_monitor_action_group.actiongroup.id]
email_subject = "Disk storage at less than 10%"
custom_webhook_payload = "{ \"text\" : \"Warning: Storage has less than 10% diskspace remaining!\"}"
}
Related
I want to implement Azure Service Bus Topic/Subscription. Something like this
I'm looking at the Python implementation in the Azure Docs. What I don't understand, is when the message is sent, how does it know which subscription to go to?
def send_single_message(sender):
# create a Service Bus message
message = ServiceBusMessage("Single Message")
# send the message to the topic
sender.send_messages(message)
print("Sent a single message")
# create a Service Bus client using the connection string
servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR, logging_enable=True)
with servicebus_client:
# get a Topic Sender object to send messages to the topic
sender = servicebus_client.get_topic_sender(topic_name=TOPIC_NAME)
with sender:
# send one message
send_single_message(sender)
print("Done sending messages")
print("-----------------------")
What I don't understand, is when the message is sent, how does it know
which subscription to go to?
This is accomplished through topic filters. Each message that gets sent to a Topic is "kind of broadcasted" (for the lack of better term) to every Subscription and the Subscription only accepts a message when that message matches one of the filter rules specified for that Subscription.
You can learn more about it here: https://learn.microsoft.com/en-us/azure/service-bus-messaging/topic-filters.
I am creating a Azure Logic App. The workflow is triggered by "When a message is received in a topic subscription (auto-complete)".
The message is simple JSON format:
{
"FirstName":"Test",
"LastName":"User",
"CreatedAt":"2022-03-26T19:27:07.6885324-04:00"
}
I want to insert the record into Salesforce. But I am unable to insert the record as I am not able to extract properties from message.
You can use Parse_JSON in this case. As the result we receive from the trigger is of base64, we need to use
decodeBase64(triggerBody()?['ContentData'])
Here is the screenshot of my logic app:
RESULT:
There is one requirement to send an email upon unsuccessful web-jobs only. There are 16 web-jobs which are deployed and running successfully on azure portal. I have suggested to modify the code for existing web-job but client does not want to modify web-jobs. He wants to add something extra which does not require to modify web-jobs anymore. I am confused, without modifying web-jobs, how can I send an email? I searched a lot on google and stack-overflow but didn't get anything.
How can I implement this?
Few of the workarounds for getting the notification to email for WebJobs Status:
Using ErroTrigger and SendGrid extensions. you can do the Notifications sending to email for the WebJob SDK.
check this article on how to set that up which uses both extensions to send an email if an error occurred 10 times in 30 minutes window with a throttle up to 1 hour.
public static void ErrorMonitor(
[ErrorTrigger("0:30:00", 10, Throttle = "1:00:00") TraceFilter filter,
[SendGrid] SendGridMessage message)
{
message.Subject = "WebJobs Error Alert";
message.Text = filter.GetDetailedMessage(5)
}
If you aren't using the WebJob SDK, then unfortunately there aren't any events for continuous webjobs. There is only one for triggered jobs.
Also, visit this MSFT Doc and SO Thread for information on setting up the email alerts with App Services.
Due to an issue that I've been dealing with Azure B2C, I was thinking of using notification webhooks to receive information on when a user was created/updated.
While I'm able to create a subscription to the users resource, the webhook won't fire off when I actually create/update a user via the Graph API.
I created the subscription as follows:
POST https://graph.microsoft.com/v1.0/subscriptions
{
"changeType":"updated",
"notificationUrl":"https://a7500b01de1c.ngrok.io/b2chook/Users",
"resource":"users",
"expirationDateTime":"2021-08-09T01:50:17.699528+00:00"
}
The webhook that's listening into the subscription is being done in Python via Flask.
Here's the current code that's written up to receive the webhook notification:
class B2CUserHook(Resource):
#staticmethod
def post():
logger.debug(f"Microsoft Graph API notified the endpoint!")
if "validationToken" in request.args:
token = request.args.get('validationToken')
#res = make_response(token, 201)
#res.mimetype = "text/plain"
logger.debug(f"Token to return back to Graph API: {token}")
return Response(token, mimetype="text/plain")
return Response(status=202)
With the url being declared as a resource:
api.add_resource(user_controller.B2CUserHook, "/b2chook/Users")
So, how exactly can I fix this issue so that I can receive the notification?
It says it in the linked document:
Azure AD B2C tenants are not supported
I use Notification Hubs to send Notifications to IPhone and Windows Store app. The IPhone is working perfectly fine, but there is some issue with Windows Store when sending the notification.
Error: The Push Notification System handle for the registration is invalid.
Template:
String WindowsTemplateStr = #"<toast><visual><binding template=""ToastImageAndText03""><image id=""1"" src=""https://"" alt=""Customer""/><text id=""1"">$(headlineText)</text><text id=""2"">$(bodyText)</text></binding></visual></toast>";
I use this code to register:
registration = await hubClient.CreateWindowsTemplateRegistrationAsync(userDeviceInformation.ChannelUri, Templates.WindowsNotificationTemplate,
new string[]
{
userDeviceInformation.InstallationId,
userDeviceInformation.UserName
});
The registration goes through fine and I can see the tags properly associated using "Service Bus Explorer".
When I try to send the Notification this is what I do:
notification.Add("src", ImageUrl);
notification.Add("headlineText", String.Format("Message from {0}", fullName));
notification.Add("bodyText", String.Format("Message {0}", message));
When the notification is sent, nothing is received on the device; and I see the registration is also being deleted.
I can't seem to find what is causing this behavior.
Any ideas ?
If WNS returns invalid handle then the corresponding registration will be removed from the notification hubs.
You can use test send to check the error details:
http://msdn.microsoft.com/en-us/library/microsoft.servicebus.notifications.notificationhubclient.enabletestsend.aspx