-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Library name and version
Azure.ResourceManager.AlertsManagement 1.1.1
Describe the bug
Package expects alertId
of a ServiceAlert to be of type System.Guid and thus cannot handle alerts coming from a "Activity log alert rule"
Example: ffffd3c4498f509cff79781d5198691d48d10f249e6e693c4ca0c501e588f000
The equivalent calls to
https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/ffffd3c4498f509cff79781d5198691d48d10f249e6e693c4ca0c501e588f000?api-version=2019-05-05-preview
https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/ffffd3c4498f509cff79781d5198691d48d10f249e6e693c4ca0c501e588f000/history?api-version=2019-05-05-preview
works just fine as expected
Expected behavior
When following the reproduction steps no FormatExceptions are thrown
Actual behavior
When running the code, FormatExceptions are thrown when encountering alerts coming from a "Activity log alert rule" as is has a non-guid alertId
Reproduction Steps
Setup a "Activity log alert rule"
Services: all
Regions: all
Event types: all
Wait
Wait for any alert to appear in https://portal.azure.com/#view/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/~/alertsV2 for the created log alert rule and run the code below
var subscription = _armClient.GetSubscriptionResource(SubscriptionResource.CreateResourceIdentifier(subscriptionId));
var serviceAlertCollection = subscription.GetServiceAlerts();
var options = new ServiceAlertCollectionGetAllOptions
{
TimeRange = TimeRangeFilter.ThirtyDays
};
await foreach (var res in serviceAlertCollection.GetAllAsync(options))
{
if (!Guid.TryParse(res.Id.Name, out var _))
{
Console.WriteLine(res.Id.Name);
}
else
{
continue;
}
var alert = await res.GetAsync();
var history = await res.GetHistoryAsync();
}
Environment
No response