Skip to content

Commit

Permalink
Fixed VulnerabilityAssessmentInvalidPolicy error for table azure_sql_…
Browse files Browse the repository at this point in the history
…database closes #551 (#552)
  • Loading branch information
ParthaI authored Jan 10, 2023
1 parent 5a406c9 commit 369d87a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions azure/table_azure_sql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,18 @@ func listSqlDatabaseVulnerabilityAssessmentScans(ctx context.Context, d *plugin.

client := sqlV5.NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(session.ResourceManagerEndpoint, subscriptionID)
client.Authorizer = session.Authorizer
var vulnerabilityAssessmentScanRecords []map[string]interface{}

op, err := client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName)
if err != nil {
// API throws "VulnerabilityAssessmentInvalidPolicy" error if Vulnerability Assessment settings don't exist or invalid storage specified in settings.
// https://learn.microsoft.com/en-us/rest/api/sql/2022-05-01-preview/database-vulnerability-assessment-scans/list-by-database?tabs=HTTP
if strings.Contains(err.Error(), "VulnerabilityAssessmentInvalidPolicy") {
return vulnerabilityAssessmentScanRecords, nil
}
return nil, err
}

var vulnerabilityAssessmentScanRecords []map[string]interface{}

for _, i := range op.Values() {
objectMap := make(map[string]interface{})
if i.ID != nil {
Expand Down

0 comments on commit 369d87a

Please sign in to comment.