Skip to content

[BUG] ServiceAlerts incorrectly expects alertId to be of type System.Guid #48991

@lanni-energinet

Description

@lanni-energinet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARMMgmtThis issue is related to a management package.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions