Server DevOps Audit Settings - Create Or Update

建立或更新伺服器的 DevOps 稽核設定。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/Default?api-version=2025-01-01

URI 參數

名稱 位於 必要 類型 Description
devOpsAuditingSettingsName
path True

DevOpsAuditingSettingsName

resourceGroupName
path True

string

minLength: 1
maxLength: 90

資源群組的名稱。 名稱不區分大小寫。

serverName
path True

string

伺服器的名稱。

subscriptionId
path True

string (uuid)

目標訂用帳戶的標識碼。 此值必須是 UUID。

api-version
query True

string

minLength: 1

用於此作業的 API 版本。

要求本文

名稱 必要 類型 Description
properties.state True

BlobAuditingPolicyState

指定稽核的狀態。 如果狀態為 Enabled,則需要 storageEndpoint 或 isAzureMonitorTargetEnabled。

properties.isAzureMonitorTargetEnabled

boolean

指定是否將 DevOps 稽核事件送至 Azure 監視器。 若要將事件傳送到 Azure 監視器,請將「State」設為「Enabled」,「IsAzureMonitorTargetEnabled」為 true。

使用 REST API 設定 DevOps 稽核時,也應該在 master 資料庫上建立具有 'DevOpsOperationsAudit' 診斷記錄類別的診斷設定。

診斷設定 URI 格式:PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview

如需詳細資訊,請參閱 診斷設定 REST API 或 診斷設定 PowerShell

properties.isManagedIdentityInUse

boolean

指定受控識別是否用來存取 Blob 記憶體

properties.storageAccountAccessKey

string (password)

指定稽核記憶體帳戶的標識碼金鑰。 如果狀態為 Enabled 且 storageEndpoint 已指定,則未指定 storageAccountAccessKey 會使用 SQL Server 系統指派的受控識別來存取記憶體。 使用受控識別驗證的必要條件:

  1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD).
  2. 透過在伺服器身份中新增「Storage Blob Data Contributor」RBAC 角色,授予 SQL Server 身份存取權。 如需詳細資訊,請參閱使用受控識別驗證對記憶體 稽核
properties.storageAccountSubscriptionId

string (uuid)

指定 Blob 記憶體訂用帳戶標識碼。

properties.storageEndpoint

string

指定 Blob 記憶體端點(例如 https://MyAccount.blob.core.windows.net)。 如果狀態為 Enabled,則需要 storageEndpoint 或 isAzureMonitorTargetEnabled。

回應

名稱 類型 Description
200 OK

ServerDevOpsAuditingSettings

資源「ServerDevOpsAuditingSettings」更新操作成功

202 Accepted

已接受資源作業。

標題

  • Azure-AsyncOperation: string
  • Location: string
Other Status Codes

ErrorResponse

未預期的錯誤回應。

安全性

azure_auth

Azure Active Directory OAuth2 Flow。

類型: oauth2
Flow: implicit
授權 URL: https://login.microsoftonline.com/common/oauth2/authorize

範圍

名稱 Description
user_impersonation 模擬您的用戶帳戶

範例

Update a server's DevOps audit settings with all params
Update a server's DevOps audit settings with minimal input

Update a server's DevOps audit settings with all params

範例要求

PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/devAuditTestRG/providers/Microsoft.Sql/servers/devOpsAuditTestSvr/devOpsAuditingSettings/Default?api-version=2025-01-01

{
  "properties": {
    "isAzureMonitorTargetEnabled": true,
    "state": "Enabled",
    "storageAccountAccessKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "storageAccountSubscriptionId": "00000000-1234-0000-5678-000000000000",
    "storageEndpoint": "https://mystorage.blob.core.windows.net"
  }
}

範例回覆

{
  "name": "Default",
  "type": "Microsoft.Sql/servers/devOpsAuditingSettings",
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/devAuditTestRG/providers/Microsoft.Sql/servers/devOpsAuditTestSvr/devOpsAuditingSettings/default",
  "properties": {
    "isAzureMonitorTargetEnabled": true,
    "state": "Enabled",
    "storageAccountSubscriptionId": "00000000-1234-0000-5678-000000000000",
    "storageEndpoint": "https://mystorage.blob.core.windows.net"
  }
}

Update a server's DevOps audit settings with minimal input

範例要求

PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/devAuditTestRG/providers/Microsoft.Sql/servers/devOpsAuditTestSvr/devOpsAuditingSettings/Default?api-version=2025-01-01

{
  "properties": {
    "state": "Enabled",
    "storageAccountAccessKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "storageEndpoint": "https://mystorage.blob.core.windows.net"
  }
}

範例回覆

{
  "name": "Default",
  "type": "Microsoft.Sql/servers/devOpsAuditingSettings",
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/devAuditTestRG/providers/Microsoft.Sql/servers/devOpsAuditTestSvr/devOpsAuditingSettings/default",
  "properties": {
    "state": "Enabled",
    "storageAccountSubscriptionId": "00000000-1234-0000-5678-000000000000",
    "storageEndpoint": "https://mystorage.blob.core.windows.net"
  }
}

定義

名稱 Description
BlobAuditingPolicyState

指定稽核的狀態。 如果狀態為 Enabled,則需要 storageEndpoint 或 isAzureMonitorTargetEnabled。

createdByType

建立資源的身分識別類型。

DevOpsAuditingSettingsName
ErrorAdditionalInfo

資源管理錯誤附加資訊。

ErrorDetail

錯誤詳細資料。

ErrorResponse

錯誤回應

ServerDevOpsAuditingSettings

伺服器DevOps稽核設定。

systemData

與建立和上次修改資源相關的元數據。

BlobAuditingPolicyState

指定稽核的狀態。 如果狀態為 Enabled,則需要 storageEndpoint 或 isAzureMonitorTargetEnabled。

值 Description
Enabled

已啟用

Disabled

Disabled

createdByType

建立資源的身分識別類型。

值 Description
User
Application
ManagedIdentity
Key

DevOpsAuditingSettingsName

值 Description
Default

預設值

ErrorAdditionalInfo

資源管理錯誤附加資訊。

名稱 類型 Description
info

object

附加資訊。

type

string

其他資訊類型。

ErrorDetail

錯誤詳細資料。

名稱 類型 Description
additionalInfo

ErrorAdditionalInfo[]

錯誤附加資訊。

code

string

錯誤碼。

details

ErrorDetail[]

錯誤詳情

message

string

錯誤訊息。

target

string

錯誤目標。

ErrorResponse

錯誤回應

名稱 類型 Description
error

ErrorDetail

錯誤物件。

ServerDevOpsAuditingSettings

伺服器DevOps稽核設定。

名稱 類型 Description
id

string (arm-id)

資源的完整資源標識碼。 例如,“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”

name

string

資源的名稱

properties.isAzureMonitorTargetEnabled

boolean

指定是否將 DevOps 稽核事件送至 Azure 監視器。 若要將事件傳送到 Azure 監視器,請將「State」設為「Enabled」,「IsAzureMonitorTargetEnabled」為 true。

使用 REST API 設定 DevOps 稽核時,也應該在 master 資料庫上建立具有 'DevOpsOperationsAudit' 診斷記錄類別的診斷設定。

診斷設定 URI 格式:PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview

如需詳細資訊,請參閱 診斷設定 REST API 或 診斷設定 PowerShell

properties.isManagedIdentityInUse

boolean

指定受控識別是否用來存取 Blob 記憶體

properties.state

BlobAuditingPolicyState

指定稽核的狀態。 如果狀態為 Enabled,則需要 storageEndpoint 或 isAzureMonitorTargetEnabled。

properties.storageAccountAccessKey

string (password)

指定稽核記憶體帳戶的標識碼金鑰。 如果狀態為 Enabled 且 storageEndpoint 已指定,則未指定 storageAccountAccessKey 會使用 SQL Server 系統指派的受控識別來存取記憶體。 使用受控識別驗證的必要條件:

  1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD).
  2. 透過在伺服器身份中新增「Storage Blob Data Contributor」RBAC 角色,授予 SQL Server 身份存取權。 如需詳細資訊,請參閱使用受控識別驗證對記憶體 稽核
properties.storageAccountSubscriptionId

string (uuid)

指定 Blob 記憶體訂用帳戶標識碼。

properties.storageEndpoint

string

指定 Blob 記憶體端點(例如 https://MyAccount.blob.core.windows.net)。 如果狀態為 Enabled,則需要 storageEndpoint 或 isAzureMonitorTargetEnabled。

systemData

systemData

Azure Resource Manager 包含 createdBy 與 modifiedBy 資訊的元資料。

type

string

資源的類型。 例如:「Microsoft。運算/虛擬機器」或「Microsoft」。儲存/儲存帳號」

systemData

與建立和上次修改資源相關的元數據。

名稱 類型 Description
createdAt

string (date-time)

資源建立的時間戳(UTC)。

createdBy

string

建立資源的身分識別。

createdByType

createdByType

建立資源的身分識別類型。

lastModifiedAt

string (date-time)

資源上次修改的時間戳記 (UTC)

lastModifiedBy

string

上次修改資源的身分識別。

lastModifiedByType

createdByType

上次修改資源的身分識別類型。