有一个选项可以使用不需要存储帐户的快速配置来执行漏洞评估。
我想使用 AzAPI 更新资源来设置此选项,但我在resource "azapi_resource" "symbolicname" {
type = "Microsoft.Sql/servers/vulnerabilityAssessments@2022-05-01-preview"
name = "default"
parent_id = "string"
body = jsonencode({
properties = {
recurringScans = {
emails = [
"string"
]
emailSubscriptionAdmins = bool
isEnabled = bool
}
storageAccountAccessKey = "string"
storageContainerPath = "string"
storageContainerSasKey = "string"
}
})
}
可以吗?
如何使用 AzAPI 提供程序在 Azure SQL Server 上启用快速漏洞评估:在解决您的要求后,我发现有
“没有直接的方法可以利用二头肌在 SQL Server 上自动执行快速漏洞评估”。您必须使用 Azure PowerShell
或
CLI
才能使其在 Azure 门户之外运行。我尝试了使用
azapi_update_resource
资源的替代方法来启用漏洞评估,但是如果您想使用二头肌,则只有在添加
storagecontainerpath
属性时它才能正常工作。
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
version = "1.9.0"
}
}
}
provider "azurerm"{
features{}
}
provider "azapi"{}
data "azurerm_resource_group" "example"{
name = "xxxx"
}
data "azurerm_mssql_server" "example"{
name = "newser"
resource_group_name = data.azurerm_resource_group.example.name
}
data "azurerm_mssql_database" "example" {
name = "newdb"
server_id = data.azurerm_mssql_server.example.id
}
resource "azapi_update_resource" "example" {
type = "Microsoft.Sql/servers/vulnerabilityAssessments@2022-05-01-preview"
name = "expressjahc"
parent_id = data.azurerm_mssql_server.example.id
body = jsonencode({
properties = {
recurringScans = {
isEnabled = true
}
storageContainerPath = "https://<storageaccount>.blob.core.windows.net/new"
}
})
}
部署成功: