Azure / Azure/azure-powershell
all cmdlets regarding IAAS/sql server on VM's vulnerability assessments are not working due to wrong API version
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
consider one of the example commands: Add-AzSecuritySqlVulnerabilityAssessmentBaseline. When executing this command (or any related one), we get issues due to the hardcoded API version the cmdlets need AND which is not possible to register anymore these days.
complete output:
Add-AzSecuritySqlVulnerabilityAssessmentBaseline : No registered resource provider found for location 'westeurope' and API version '2020-07-01-preview' for type 'SqlVirtualMachines'. The supported api-versions are '2017-03-01-preview,
2021-11-01-preview, 2022-02-01-preview, 2022-02-01, 2022-07-01-preview, 2022-08-01-preview, 2023-01-01-preview'. The supported locations are 'australiacentral, australiacentral2, australiaeast, australiasoutheast, brazilsouth,
canadacentral, canadaeast, centralindia, centralus, eastasia, eastus, eastus2, francecentral, francesouth, germanywestcentral, israelcentral, italynorth, japaneast, japanwest, jioindiawest, koreacentral, koreasouth, northcentralus,
northeurope, norwayeast, polandcentral, qatarcentral, southafricanorth, southcentralus, southindia, southeastasia, swedencentral, switzerlandnorth, uaecentral, uaenorth, uksouth, ukwest, westcentralus, westeurope, westindia, westus,
westus2, westus3'.
At line:1 char:1
+ Add-AzSecuritySqlVulnerabilityAssessmentBaseline -RuleId VA1258 -Work ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzSecurityS...essmentBaseline], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.SecurityCenter.Cmdlets.SqlVulnerabilityAssessment.AddSecuritySqlVulnerabilityAssessmentBaseline
### Issue script & Debug output
```PowerShell
$wsid = "b4233c37-847a-4711-a33b-a2472f447ae7"
$vmresourceid = "/subscriptions/669de659-8bf5-479d-9495-35a71610bd48/resourceGroups/na-atl-tst/providers/Microsoft.Compute/virtualMachines/na-atl-tst-1"
$srv = "na-atl-tst-1\MSSQLSERVER"
$db = "master"
Add-AzSecuritySqlVulnerabilityAssessmentBaseline -RuleId VA1258 -WorkspaceId $wsid -server $srv -database $db -Baseline @( , @("ITINERISNV\nibro")) -ResourceId $vmresourceid
```
### Environment data
```PowerShell
PS C:\Users\ChSau> $psversiontable
Name Value
---- -----
PSVersion 5.1.19041.3031
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3031
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Value
---- -----
PSVersion 7.3.7
PSEdition Core
GitCommitId 7.3.7
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
PS C:\Users\ChSau> get-module az.security
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.0 az.security {Add-AzSecurityAdaptiveNetworkHardening
```
### Error output
```PowerShell
RequestId : 329cac36-049f-4bfc-ae58-7f14fcd38db6
Message : No registered resource provider found for location 'westeurope' and API version '2020-07-01-preview' for type 'virtualMachines'. The supported api-versions are '2015-05-01-preview, 2015-06-15, 2016-03-30,
2016-04-30-preview, 2016-08-30, 2017-03-30, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01, 2019-03-01, 2019-07-01, 2019-12-01, 2020-06-01, 2020-12-01, 2021-03-01, 2021-04-01, 2021-07-01, 2021-11-01, 2022-03-01,
2022-08-01, 2022-11-01, 2023-03-01, 2023-07-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest,
australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral,
southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, jioindiawest, westus3, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral'.
ServerMessage : NoRegisteredProviderFound: No registered resource provider found for location 'westeurope' and API version '2020-07-01-preview' for type 'virtualMachines'. The supported api-versions are '2015-05-01-preview,
2015-06-15, 2016-03-30, 2016-04-30-preview, 2016-08-30, 2017-03-30, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01, 2019-03-01, 2019-07-01, 2019-12-01, 2020-06-01, 2020-12-01, 2021-03-01, 2021-04-01, 2021-07-01,
2021-11-01, 2022-03-01, 2022-08-01, 2022-11-01, 2023-03-01, 2023-07-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia,
southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest,
koreacentral, koreasouth, francecentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, jioindiawest, westus3, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral'.
(System.Collections.Generic.List`1[Microsoft.Rest.Azure.CloudError])
ServerResponse : {BadRequest}
RequestMessage : {GET https://management.azure.com//subscriptions/669de659-8bf5-479d-9495-35a71610bd48/resourceGroups/na-atl-tst/providers/Microsoft.Compute/virtualMachines/na-atl-tst-1/sqlServers/na-atl-tst-1/MSSQLSERVER/databases/mast
er/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules?workspaceId=b4233c37-847a-4711-a33b-a2472f447ae7&api-version=2020-07-01-preview}
InvocationInfo : {Get-AzSecuritySqlVulnerabilityAssessmentBaseline}
Line : get-AzSecuritySqlVulnerabilityAssessmentBaseline -ResourceId $vmresourceid `
Position : At line:1 char:1
+ get-AzSecuritySqlVulnerabilityAssessmentBaseline -ResourceId $vmresou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StackTrace : at Microsoft.Azure.Management.Security.SqlVulnerabilityAssessmentBaselineRulesOperations.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Commands.SecurityCenter.Cmdlets.SqlVulnerabilityAssessment.GetSecuritySqlVulnerabilityAssessmentBaseline.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
HistoryId : 6
```
Contributor guide
Assessment
This issue has not been assessed yet.