Azure SQL Server审核EventHub Bicep

cxfofazt  于 2023-06-30  发布在  SQL Server
关注(0)|答案(1)|浏览(125)

我尝试在二头肌中复制以下设置:

1
当我手动添加并检查ARM以获取指南时,除了以下内容外,没有其他内容:

{
        "type": "Microsoft.Sql/servers/auditingSettings",
        "apiVersion": "2022-08-01-preview",
        "name": "[concat(parameters('sqlServer'), '/Default')]",
        "dependsOn": [
            "[resourceId('Microsoft.Sql/servers', parameters('sqlServer'))]"
        ],
        "properties": {
            "retentionDays": 0,
            "auditActionsAndGroups": [
                "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP",
                "FAILED_DATABASE_AUTHENTICATION_GROUP",
                "BATCH_COMPLETED_GROUP"
            ],
            "isAzureMonitorTargetEnabled": true,
            "isManagedIdentityInUse": false,
            "state": "Enabled",
            "storageAccountSubscriptionId": "00000000-0000-0000-0000-000000000000"
        }

这仅指一个存储帐户,我尚未设置该帐户,并且显示的是子ID 0000,而不是我的掩码。
在API上查看此Microsoft article,没有用于设置Event Hub的属性,只有一个存储帐户。这是否可以通过IaC实现?
先谢谢你了

a7qyws3x

a7qyws3x1#

要配置eventhublog analytics,请不要指定storageAccountSubscriptionId属性:

param sqlServerName string = ''

// Get a reference to sql server
resource sqlServer 'Microsoft.Sql/servers@2020-11-01-preview' existing =  {
  name: sqlServerName
}

// Enable SQL Server auditing
resource enableSqlAuditing 'Microsoft.Sql/servers/auditingSettings@2021-02-01-preview' = {
  name: 'auditing'
  parent: sqlServer
  properties: {
    isAzureMonitorTargetEnabled: true
    state: 'Enabled'
    auditActionsAndGroups: [
      'SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP'
      'FAILED_DATABASE_AUTHENTICATION_GROUP'
      'BATCH_COMPLETED_GROUP'
    ]
  }
}

然后,您可以使用诊断设置发送SQLSecurityAuditEvents

resource masterDb 'Microsoft.Sql/servers/databases@2020-08-01-preview' existing = {
  name: 'master'
  parent: sqlServer
}

// Create diagnostic settings
resource SqlSecurityAuditLogs 'Microsoft.Insights/diagnosticSettings@2017-05-01-preview' = {
  scope: masterDb
  name: 'SQLSecurityAuditLogs'
  properties: {
    eventHubName: '...'
    eventHubAuthorizationRuleId: '...'
    logs: [
      {
        category: 'SQLSecurityAuditEvents'
        enabled: true
        ...
      }
    ]
  }
}

相关问题