Executes a Vulnerability Assessment database scan.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/default/initiateScan?api-version=2023-08-01
URI Parameters
Name
In
Required
Type
Description
databaseName
path
True
string
The name of the database.
resourceGroupName
path
True
string
The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
serverName
path
True
string
The name of the server.
subscriptionId
path
True
string
The subscription ID that identifies an Azure subscription.
400 SqlVulnerabilityAssessmentIsDisabled - SQL vulnerability assessment feature is disabled. please enable the feature before executing other SQL vulnerability assessment operations.
400 InvalidVulnerabilityAssessmentOperationRequest - The vulnerability assessment operation request does not exist or has no properties object.
400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.
404 SubscriptionDoesNotHaveServer - The requested server was not found
404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.
404 SourceDatabaseNotFound - The source database does not exist.
404 OperationIdNotFound - The operation with Id does not exist.
409 DatabaseVulnerabilityAssessmentScanIsAlreadyInProgress - SQL Vulnerability Assessment scan is already in progress
409 VulnerabilityAssessmentStoragelessIsEnabled - Vulnerability Assessment is enabled on this server or one of its underlying databases with an incompatible version. Additional troubleshooting information can be found https://aka.ms/SQLVAStoragelessDocumentation.
409 CannotCancelOperation - The management operation is in a state that cannot be cancelled.
409 OperationCancelled - The operation has been cancelled by user.
409 OperationInterrupted - The operation on the resource could not be completed because it was interrupted by another operation on the same resource.
429 SubscriptionTooManyCreateUpdateRequests - Requests beyond max requests that can be processed by available resources.
429 SubscriptionTooManyRequests - Requests beyond max requests that can be processed by available resources.
500 DatabaseIsUnavailable - Loading failed. Please try again later.
500 OperationTimedOut - The operation timed out and automatically rolled back. Please retry the operation.
503 TooManyRequests - Requests beyond max requests that can be processed by available resources.
Examples
Executes a database's vulnerability assessment scan.
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/vulnerabilityassessmenttest-4711/providers/Microsoft.Sql/servers/vulnerabilityassessmenttest-6411/databases/testdb/sqlVulnerabilityAssessments/default/initiateScan?api-version=2023-08-01
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2023-08-01/examples/DatabaseSqlVulnerabilityAssessmentScansExecute.json
// this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentExecuteScan_Execute" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure
// for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "vulnerabilityassessmenttest-4711";
string serverName = "vulnerabilityassessmenttest-6411";
string databaseName = "testdb";
VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default;
ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName);
SqlDatabaseSqlVulnerabilityAssessmentResource sqlDatabaseSqlVulnerabilityAssessment = client.GetSqlDatabaseSqlVulnerabilityAssessmentResource(sqlDatabaseSqlVulnerabilityAssessmentResourceId);
// invoke the operation
await sqlDatabaseSqlVulnerabilityAssessment.ExecuteScanAsync(WaitUntil.Completed);
Console.WriteLine("Succeeded");