Azure / Azure/azure-powershell
Convert-AzSqlDatabaseVulnerabilityAssessmentScan - An unexpected error occured [sic]
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
I have a script that uses Convert-AzSqlDatabaseVulnerabilityAssessmentScan to convert the json files generated by Start-AzSqlDatabaseVulnerabilityAssessmentScan to nicely formatted Excel files. This last worked on Friday 1/31.
However, when I ran the same script on Friday 2/7, it failed with "An unexpected error occured [sic] while processing the request."
I tried it again today and encountered the same error.
### Issue script & Debug output
```PowerShell
DEBUG: AzureQoSEvent: Module: Az.Sql:6.0.1; CommandName: Start-AzSqlDatabaseVulnerabilityAssessmentScan; PSVersion: 7.5.0; IsSuccess: True; Duration: 00:00:57.1499686; SanitizeDuration: 00:00:00.0005116
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - StartAzureSqlDatabaseVulnerabilityAssessmentScan end processing.
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet = [Get-AzContext]. Returning default value [True].
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Accounts:4.0.2; CommandName: Get-AzContext; PSVersion: 7.5.0; IsSuccess: True; Duration: 00:00:00.0022629; SanitizeDuration: 00:00:00.0000294
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - GetAzureRMContextCommand end processing.
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet = [Get-AzContext]. Returning default value [True].
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Accounts:4.0.2; CommandName: Get-AzContext; PSVersion: 7.5.0; IsSuccess: True; Duration: 00:00:00.0027381; SanitizeDuration: 00:00:00.0000398
DEBUG: 12:17:42 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:43 PM - GetAzureRMContextCommand end processing.
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:43 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet = [Get-AzContext]. Returning default value [True].
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Accounts:4.0.2; CommandName: Get-AzContext; PSVersion: 7.5.0; IsSuccess: True; Duration: 00:00:00.0037380; SanitizeDuration: 00:00:00.0000387
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:43 PM - GetAzureRMContextCommand end processing.
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 12:17:43 PM - ConvertAzureSqlDatabaseVulnerabilityAssessmentScan begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 12:17:43 PM - using account id [REDACTED]...
DEBUG: 12:17:43 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Sql], Cmdlet = [Convert-AzSqlDatabaseVulnerabilityAssessmentScan]. Returning default value [True].
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Sql/servers//databases//vulnerabilityAssessments/default/scans//export?api-version=2020-11-01-preview
Headers:
Accept-Language : en-US
x-ms-client-request-id : c89d83e1-fd3e-40a9-bf92-38bc9043d489
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
InternalServerError
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-request-id : [REDACTED]
x-ms-failure-cause : service
x-ms-ratelimit-remaining-subscription-writes: 200
x-ms-ratelimit-remaining-subscription-global-writes: 3000
x-ms-correlation-request-id : 6688189c-a13a-43d5-b01d-fbdef1c5eb3e
x-ms-routing-request-id : WESTUS:20250210T202113Z:6688189c-a13a-43d5-b01d-fbdef1c5eb3e
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: F40D2051F0A9453E862B1970D56E1795 Ref B: SJC211051201025 Ref C: 2025-02-10T20:20:26Z
Date : Mon, 10 Feb 2025 20:21:13 GMT
Body:
{
"error": {
"code": "InternalServerError",
"message": "An unexpected error occured while processing the request. Tracking ID: '[REDACTED]'"
}
}
DEBUG: 12:21:13 PM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [Az.Sql], Cmdlet = [Convert-AzSqlDatabaseVulnerabilityAssessmentScan]. Returning default value [False].
Convert-AzSqlDatabaseVulnerabilityAssessmentScan: C:\Scripts\AzSql-IssueDemo.ps1:32:30
Line |
32 | … nResult = $sqlScan | Convert-AzSqlDatabaseVulnerabilityAssessmentScan
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| An unexpected error occured while processing the request. Tracking ID:
| '[REDACTED]'
```
### Environment data
```PowerShell
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
OS Microsoft Windows 10.0.22631
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> Get-Module Az*
ModuleType : Script
Version : 4.0.2
PreRelease :
Name : Az.Accounts
ExportedCommands : {[Add-AzEnvironment, Add-AzEnvironment], [Clear-AzConfig,
Clear-AzConfig], [Clear-AzContext, Clear-AzContext],
[Clear-AzDefault, Clear-AzDefault]…}
ModuleType : Script
Version : 6.0.1
PreRelease :
Name : Az.Sql
ExportedCommands : {[Add-AzSqlDatabaseToFailoverGroup,
Add-AzSqlDatabaseToFailoverGroup], [Add-AzSqlElasticJobStep,
Add-AzSqlElasticJobStep], [Add-AzSqlElasticJobTarget,
Add-AzSqlElasticJobTarget], [Add-AzSqlInstanceKeyVaultKey,
Add-AzSqlInstanceKeyVaultKey]…}
```
### Error output
```PowerShell
PS> Resolve-AzError
RequestId : [REDACTED]
Message : An unexpected error occured while processing the request.
Tracking ID: '[REDACTED]'
ServerMessage : InternalServerError: An unexpected error occured while
processing the request. Tracking ID:
'[REDACTED]' (System.Collections.Generic.List`1[Microsoft.Rest.Azure.CloudError])
ServerResponse : {InternalServerError}
RequestMessage : {POST https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Sql/servers//databases//vulnerabilityAssessments/default/scans//export?api-version=2020-11-01-preview}
InvocationInfo : {Convert-AzSqlDatabaseVulnerabilityAssessmentScan}
Line : $scanResult = $sqlScan |
Convert-AzSqlDatabaseVulnerabilityAssessmentScan
Position : At C:\Scripts\AzSql-IssueDemo.ps1:32
char:30
+ … nResult = $sqlScan |
Convert-AzSqlDatabaseVulnerabilityAssessmentScan
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StackTrace : at Microsoft.Azure.Management.Sql.DatabaseVulnerabilityAssess
mentScansOperations.ExportWithHttpMessagesAsync(String
resourceGroupName, String serverName, String databaseName,
String scanId, Dictionary`2 customHeaders, CancellationToken
cancellationToken)
at Microsoft.Azure.Management.Sql.DatabaseVulnerabilityAssess
mentScansOperationsExtensions.ExportAsync(IDatabaseVulnerability
AssessmentScansOperations operations, String resourceGroupName,
String serverName, String databaseName, String scanId,
CancellationToken cancellationToken)
at Microsoft.Azure.Management.Sql.DatabaseVulnerabilityAssess
mentScansOperationsExtensions.Export(IDatabaseVulnerabilityAsses
smentScansOperations operations, String resourceGroupName,
String serverName, String databaseName, String scanId)
at Microsoft.Azure.Commands.Sql.VulnerabilityAssessment.Servi
ces.VulnerabilityAssessmentEndpointsCommunicator.ConvertDatabase
VulnerabilityAssessmentScan(String resourceGroupName, String
serverName, String databaseName, String scanId)
at Microsoft.Azure.Commands.Sql.VulnerabilityAssessment.Servi
ces.SqlVulnerabilityAssessmentScanAdapter.ConvertVulnerabilityAs
sessmentScan(String resourceGroup, String serverName, String
databaseName, String scanId, ApplyToType applyToType)
at Microsoft.Azure.Commands.Sql.VulnerabilityAssessment.Cmdle
t.VulnerabilityAssessmentScan.ConvertAzureSqlVulnerabilityAssess
mentScanBase.PersistChanges(VulnerabilityAssessmentScanExportMod
el model)
at Microsoft.Azure.Commands.Sql.Common.AzureSqlCmdletBase`2.<
>c__DisplayClass16_0.b__0()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCm
dlet.ConfirmAction(String processMessage, String target, Action
action)
at Microsoft.Azure.Commands.Sql.Common.AzureSqlCmdletBase`2.E
xecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExt
ensions.<>c__3`1.b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExt
ensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1
executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExt
ensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCm
dlet.ProcessRecord()
```
Contributor guide
Research direction
Start at Convert-AzSqlDatabaseVulnerabilityAssessmentScan and reproduce the reported script with Az.Sql 6.0.1, focusing on the POST export request and its InternalServerError response. Use the supplied Resolve-AzError output and stack trace to determine whether the failure is in the cmdlet or the Azure SQL service; done requires an identified cause and a confirmed resolution or clear service-side diagnosis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell, sql
- Domain
- api, cloud, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100