[BUG] Arm Client doesn't use the set ApiVersion in ArmClientOptions when working with Log Analytics Workspaces
See original GitHub issueLibrary 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:
- Created 6 months ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Thank you for your feedback. Tagging and routing to the team member best able to assist.
@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.