how to log service topic messages in azure? - azure

I found a way to query the AzureActivity Log in Azure to get a result set of changes that were made to Service Bus Topics like add, rename, delete. The result of changes includes info like TimeGenerated, HttpRequest, ResourceId. But this result set of changes is only for structural changes.
I'd like to configure my Azure instance to log the actual messages that are added to the topic, not just structural changes to a topic definition. The result set should include the same fields of TimeGenerated, HttpRequest, ResourceId. I'm guessing that there's a way to configure Azure to do this but I'm not sure how this would be done. Can you advise how to do this?

I don't think you can query the Activity logs specific to message processing.
All the management operations like create, edit, delete are possible in Azure portal, so they are capturing those events and allow us to query them.
There is no support for any kind of message processing in Azure portal and it is possible only through APIs and Libraries. So, they cannot track something which happened outside the portal.

Related

Azure deleted & created resources

I want to have a control in Azure regarding new and deleted items
I need a query to know "who" and "when" a resource is created or deleted in Azure
Is this possible? How can I do this query?
I need a query to know "who" and "when" a resource is created or
deleted in Azure
Is this possible? How can I do this query?
Whenever a resource is created or deleted, information about that operation is stored in Azure Activity Logs. You should be able to find the information by querying that.
Another alternative would be to make use of Azure Event Grid and subscribe to Subscription Events. You can subscribe to Microsoft.Resources.ResourceWriteSuccess (for creation/updation of resources) and Microsoft.Resources.ResourceDeleteSuccess (for resource deletion) events and take action on these events in near real time.
Within the Azure Portal, you can view these types of events from the past 90 days in the Activity Log blade.
For access to events occurring more than 90 days in the past, you need to pre-emptively set up log archival as detailed in the Export the Azure Activity Log article.
If you are planning to use the export Activity Log feature, please make sure you use the new diagnostic setting feature on Azure subscription to export Activity Logs. This feature offers multiple improvements over the old features such as Logprofiles or the Activity Log solution (Log Analytics).
https://learn.microsoft.com/en-us/azure/azure-monitor/platform/activity-log-collect
https://learn.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-settings-template

Is there a way to trigger a Logic App on a deletion of a record in an Azure SQL table?

Is there a way to trigger a Logic App on a deletion of a record in an Azure SQL table?
I've checked the SQL Connector and there is only When an item is created and When an item is modified, which gives me the C and U in CRUD, but sadly there isn't an out-of-the-box trigger for the D.
I can think of some awful way of polling to get record deletions, but I'm hoping that there is a cleaner solution that some bright person has come up with, however I've had no joy with the Google searching.
I would look at the Azure Event Grid. Azure Event Grid allows you to easily build applications with event-based architectures. First, select the Azure resource you would like to subscribe to, and then give the event handler or WebHook endpoint to send the event to. Event Grid has built-in support for events coming from Azure services, like storage blobs and resource groups. Event Grid also has support for your own events, using custom topics.
I would suggest monitoring the resource group and triggering it off the deletion from the RG. There is a tutorial that shows this same concept with a VM but you should be able to modify it to meet your needs with an Azure SQL DB.
https://learn.microsoft.com/en-us/azure/event-grid/monitor-virtual-machine-changes-event-grid-logic-app
I added an on delete trigger which adds the id of the deleted record to a secondary table. I have the logic app look for modifications on the secondary table.

Monitor specific activity logs to trigger Azure Function

Usecase: Trigger Azure Function only for predefined Azure activity logs.
I tried to configure Azure Activity logs and Export to Event Hub, but it won't allow Filter set on it. As per Azure document, the filter settings do not have an impact on export settings.
My usecase is to trigger an Azure Function only for a specific set of activity logs (say VM, VNet, NSG Create/Delete/Modify). What other Azure services can I use to accomplish this?
One option, but with some constraints, is to create Alerts at Resource Group level or even for specific resources. Alerts provide some flexibility in filtering specific events for which you would want to trigger an Action, say an Azure Func in your case.
I was thinking Azure Logic Apps would do this as well. However, to my surprise I could not find an option to add Activity Log as a trigger. Probably, it would come in the future. As Azure is updated quite frequently, keep checking every now and then to see if you get any new options to do this.

Not able to stream activity logs into Event Hub

I'm using free tier Azure account. I'm trying to configure activity logs streaming into Event Hubs as per instructions on page - https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-stream-activity-logs-event-hubs
I have created a new EventHub, Shared Access Policy called "ActivityLogsPolicy" with Manage, Send and Listen permissions.
I used this policy to configure "Export" from Activity logs however it keeps failing with error message "Create or update activity log profilesFailure"
Has anyone encountered this problem ?
I was able to get it to work as follows:
In order to make it work, you have to “Register” support for a provider called “microsoft.insights” the whole thing has look and feel of “Windows Registries” :pensive:
Search for Subscriptions in all services -> Select your subscription -> Resource Providers -> Search for “microsoft.insights” -> Enable it. Then it works
I ran into this same error after moving a subscription to a new enterprise agreement. I was not able to get it working so I needed to create a new subscription.

Can I set the Azure WebJob Dashboard Status myself?

I'm using the Azure WebJob dashboard for monitoring my jobs. I'm not happy with how far I have to drill into the into the interface to determine what's happening. I'd like to leverage the "Status" field on the webjob details page to show if a particular invocation needs attention and in cases where I consider an invocation a failure, even if it didn't blow up.
I've searched through the Azure WebJobs docs and the features of the Azure WebJobs SDK Extensions package with no luck (but I don't doubt I might have missed it). I manually setting this field possible?
I'm not happy with how far I have to drill into the into the interface to determine what's happening. I'd like to leverage the "Status" field on the webjob details page to show if a particular invocation needs attention and in cases where I consider an invocation a failure, even if it didn't blow up.
As far as I know, it seems that it does not enable us to set status field by ourselves on Azure WebJob Dashboard. If you’d like to display WebJob run details without clicking into the interface, you could try to call WebJobs API to get job runs history and retrieve output or error information from logs by requesting output_url or error_url, and then you could create a custom dashboard and populate it with the output and error details data.
No, you can't set it yourself.
The Kudu APIs may not give you enough detail for individual function instances.
Consider putting a feature request on https://github.com/Azure/azure-webjobs-sdk/
There has been some more investment in exposing a logging API directly over the storage account.

Resources