Azure / Azure/azure-powershell

Azure Sql Data Classification cmdlets sending requests to wrong api version for managed Sql databases

Open
#21,662 4 comments 0 reactions 0 assignees View on GitHub
act-codegen-extensibility-squad bug customer-reported Service Attention SQL - Data Security
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

PS cmdlets are sending requests to wrong api version for managed databases (there's no 2017-03-01, portal is using 2018-06-01) - seems to have been regressed with this PR in which cmdlets stop using SDK and have defined it's own communication with ARM [Enhance pefrormance of Data Classification Cmdlets. by bashahee · Pull Request #11629 · Azure/azure-powershell (github.com)](https://github.com/Azure/azure-powershell/pull/11629)
Other cmdlets may be impacted as well (e.g. [Remove-AzSqlDatabaseSensitivityClassification : Response status code does not indicate success: 404 (Not Found). · Issue #12304 · Azure/azure-powershell (github.com)](https://github.com/Azure/azure-powershell/issues/12304))

### Issue script & Debug output

```PowerShell
$SqlManagedInstances = Get-AzSqlInstance | ? {$_.ManagedInstanceName -match "integ" -and $_.ManagedInstanceName -match "prod"}
foreach ($SqlManagedInstance in $SqlManagedInstances) {
$Databases = $SqlManagedInstance | Get-AzSqlInstanceDatabase
foreach ($Database in $Databases) {
$SensitivityRecommendationCheck = $Database | Get-AzSqlInstanceDatabaseSensitivityClassification
if ($SensitivityRecommendationCheck.SensitivityLabels.Count -eq 0) {
$Database | Get-AzSqlInstanceDatabaseSensitivityRecommendation | Set-AzSqlInstanceDatabaseSensitivityClassification
}
}
}
```

### Environment data

```PowerShell
.
```

### Module versions

```PowerShell
.
```

### Error output

```PowerShell
InvalidApiVersionParameter and error message The api-version '2017-03-01-preview' is invalid. The supported versions are '2018-06-01-preview','2019-06-01-preview','2020-02-02-preview','2020-02-02','2020-08-01-preview','2020-08-01','2020-11-01-preview','2020-11-01','2021-02-01-preview','2021-02-01','2021-05-01-preview','2021-05-01','2021-08-01-preview','2021-08-01','2021-11-01-preview','2021-11-01','2022-02-01-preview','2022-02-01','2022-05-01-preview','2022-05-01','2022-08-01-preview','2022-08-01','2022-11-01-preview','2022-11-01','2.0'.

However, enabling debug output on the powershell command shows that it is calling api-version=2020-11-01-preview.
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing PR #11629 and the Get-AzSqlInstanceDatabaseSensitivityClassification, Get-AzSqlInstanceDatabaseSensitivityRecommendation, and Set-AzSqlInstanceDatabaseSensitivityClassification cmdlets. Reproduce the managed database request with the issue script and debug output, then compare the requested API version with the supported versions. Done means the affected cmdlets use a supported version and no longer return InvalidApiVersionParameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, powershell
Domain
api, cloud, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.