question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Arm Client doesn't use the set ApiVersion in ArmClientOptions when working with Log Analytics Workspaces

See original GitHub issue

Library name and version

Azure.ResourceManager.SecurityInsights

Describe the bug

I’m using a Sentinel instance that works on top of a West Europe log analytics workspace which as per the subscription supports API version 2022-10-01. If I create an armClient directly I get the error:

Azure.RequestFailedException: 'No registered resource provider found for location ‘westeurope’ and API version ‘2022-11-01’ for type ‘workspaces’. The supported api-versions are ‘2015-03-20, 2015-11-01-preview, 2017-01-01-preview, 2017-03-03-preview, 2017-03-15-preview, 2017-04-26-preview, 2020-03-01-preview, 2020-08-01, 2020-10-01, 2021-06-01, 2021-03-01-privatepreview, 2021-12-01-preview, 2022-10-01’. The supported locations are ‘eastus, westeurope, southeastasia, australiasoutheast, westcentralus, japaneast, uksouth, centralindia, canadacentral, westus2, australiacentral, australiaeast, francecentral, koreacentral, northeurope, centralus, eastasia, eastus2, southcentralus, northcentralus, westus, ukwest, southafricanorth, brazilsouth, switzerlandnorth, switzerlandwest, germanywestcentral, australiacentral2, uaecentral, uaenorth, japanwest, brazilsoutheast, norwayeast, norwaywest, francesouth, southindia, koreasouth, jioindiacentral, jioindiawest, qatarcentral, canadaeast, westus3, swedencentral’. Status: 400 (Bad Request) ErrorCode: NoRegisteredProviderFound

After I set ArmClientOptions as below:

ArmClientOptions armClientOptions = new ArmClientOptions(); ResourceType workspaceResourceType = new ResourceType(“Microsoft.OperationalInsights/workspaces”); armClientOptions.SetApiVersion(workspaceResourceType, “2022-10-01”); armClient = new ArmClient(credential,SI_SubscriptionId,armClientOptions );

I still get the same error.

Expected behavior

I expect when accessing the workspace resource type the API version I have set as an override be in effect. During debugging I can see that the api version override is populated in the armClient.

Actual behavior

The armClient defaults to version “2022-11-01” which is not supported instead of the override and supported version string of “2022-10-01”.

Reproduction Steps

The line where individual alert rules are being grabbed with GetSecurityInsightsAlertRule will fail with the error.

ArmClientOptions armClientOptions = new ArmClientOptions();
 ResourceType workspaceResourceType = new ResourceType("Microsoft.OperationalInsights/workspaces");
 armClientOptions.SetApiVersion(workspaceResourceType, "2022-10-01");
 armClient = new ArmClient(credential,SI_SubscriptionId,armClientOptions ); 
WorkspaceResourceIdentifier = new ResourceIdentifier(
 "/subscriptions/" +
 SI_SubscriptionId +
 "/resourceGroups/" +
 SI_SentinelInstanceResourceGroupName +
 "/providers/Microsoft.OperationalInsights/workspaces/" +
 SI_SentinelWorkspaceName);
 workspace = armClient.GetOperationalInsightsWorkspaceSecurityInsightsResource(WorkspaceResourceIdentifier);
 var alertRuleIds = workspace.GetSecurityInsightsAlertRules().Select(a => a.Id).ToList();
 foreach(var alert in alertRuleIds)
 {

 SecurityInsightsAlertRuleResource ruleResource = workspace.GetSecurityInsightsAlertRule(alert);

Environment

.Net 7.0 STS, Visual Studio 2022 Azure.ResourceManager.SecurityInsights version 1.0.1 Azure.Identity 1.8.2

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jsquirecommented, Mar 27, 2023

Thank you for your feedback. Tagging and routing to the team member best able to assist.

0reactions
ArthurMa1978commented, Aug 9, 2023

@oguzhanf, I appreciate your feedback and I think the problem is resolved, so I’m closing this issue for now. If you think that I have misunderstood your issue or closed it incorrectly, please feel free to comment on this thread and reopen the issue. I will be happy to assist you further. Thank you for your understanding and cooperation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to choose log analytics workspace for policies/ ...
I am unable to link any log analytics workspace to policies for enabling for example diagnostic logs or sentinel connector for resources.
Read more >
Azure Monitor Log Alert V2
You can scope the alert to specific subscription or resource group instead to Log Analytics workspace – By scoping the alert rule to...
Read more >
ARM Client to Deal With ARM APIs - Kloudspro
ARM Client has been installed so let's now try to run some ARM APIs. Let's call an API to list tables from Azure...
Read more >
Connect Grafana to Azure Log Analytics
In this post I demonstrate how to connect Grafana to Azure Log Analytics using the Azure Monitor data source plugin.
Read more >
Trying to set up diagnostic settings for an API arm template
I am new to ARM templates and I have the following issue: I have an ARM template which creates an API Management service...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found