設定透過 Azure Arc 啟用的 SQL Server

適用於:SQL Server

每個已啟用 Azure Arc 的伺服器都包含一組屬性,這些屬性會套用至安裝在該伺服器中的所有 SQL Server 執行個體。 在電腦上安裝適用於 SQL Server 的 Azure 延伸模組之後,您可以設定這些屬性。 不過,只有在已安裝 SQL Server 執行個體時,屬性才會生效。 在 Azure 入口網站 中,透過 Azure Arc 啟用的 SQL Server 概觀會反映 SQL Server 設定如何影響特定執行個體。

Azure 入口網站 SQL Server 設定可讓您執行下列管理工作:

  1. 設定 SQL Server 授權類型
  2. 設定 [延伸安全性修補程式] 屬性
  3. 新增至 [排除執行個體] 清單

必要條件

  • 您至少必須在組織建立的其中一個 Azure 訂閱中擔任參與者角色。 了解如何建立新的計費訂閱
  • 您擔任資源群組的參與者角色,SQL Server 執行個體將在該資源群組中註冊。 如需詳細資訊,請參閱受控的 Azure 資源群組
  • Microsoft.AzureArcDataMicrosoft.HybridCompute 資源提供者會在您針對 SQL Server 隨用隨付計費使用的每個訂閱中註冊。

註冊資源提供者

若要註冊資源提供者,請使用下列其中一種方法:

  1. 選取訂用帳戶
  2. 選擇您的訂用帳戶
  3. 在 [設定] 下,選取 [資源提供者]
  4. 搜尋 Microsoft.AzureArcDataMicrosoft.HybridCompute,然後選取 [註冊]

修改 SQL Server 設定

您可以使用 Azure 入口網站、PowerShell 或 CLI,將特定已啟用 Arc 之伺服器上的所有或部分組態設定變更為所需的狀態。

如要以單一命令為更大的範圍 (如資源群組、訂用帳戶或多個訂用帳戶) 修改 SQL Server 設定,請使用修改 modify-license-type.ps1 PowerShell 指令碼。 其會發佈為開放原始碼 SQL Server 範例,並包含逐步指示。

提示

從 Azure Cloud Shell 執行指令碼,因為:

  • 其已預安裝必要的 Azure PowerShell 模組
  • 它會自動驗證您的身分

如需詳細資料,請參閱使用 Cloud Shell 執行指令碼

在 Azure 入口網站中有兩種方式可設定 SQL Server 主機。

  • 開啟已啟用 Arc 的伺服器概觀頁面,然後選取 [SQL Server 設定],如下所示。

    Azure 入口網站中 Azure Arc 啟用之 SQL Server 的螢幕擷取畫面。

    Or

  • 開啟已啟用 Arc 的 SQL Server 概觀頁面,然後選取 [屬性]。 在 [SQL Server 設定] 下,選取需要修改的設定:

    • 授權類型
    • ESU 訂用帳戶
    • 自動更新

    Azure 入口網站 SQL Server 執行個體組態的螢幕擷取畫面。

設定授權類型屬性

選擇其中一種授權類型。 如需說明,請參閱授權類型

設定延伸安全性修補程式屬性

延伸安全性修補程式 (ESU) 適用於使用授權搭配軟體保證或隨用隨付作為授權類型的合格 SQL Server 執行個體。 如果授權類型僅限授權,則會停用啟用 ESU 訂用帳戶的選項。 請參閱 SQL Server 的延伸安全性修補程式

注意

  • 若要啟用 ESU 訂用帳戶,授權類型必須設定為「隨用隨付」或「具有軟體保證的授權」。 如果設定為 [僅限授權],則會停用 [延伸安全性修補程式] 選項。
  • 如果開啟 ESU,則授權類型在 ESU 訂用帳戶取消之前無法變更為 LicenseOnly

套用實體核心授權

如果這是虛擬機器並且您正在利用無限制虛擬化權益來授權 SQL Server 軟體或 SQL 訂用帳戶,則請選取此核取方塊。 如果選取,則 P 核心會優先,且與此 VM 關聯的 SQL Server 軟體成本或 USU 成本變成空值。

重要

  1. 在列出之提供者的基礎結構上執行的 VM 不支援 UV 權益。 如果您針對這類 VM 選取此選項,則此意圖會被忽略,而且您將需要支付 VM V 核心的費用。 如需詳細資訊,請參閱列出的提供者
  2. 如果您要設定不受上述限制的 VM,則請確定選取的授權類型符合 P 核心授權資源中設定的計費方案

新增至 [排除執行個體] 清單

您可以將特定執行個體從由 Azure 原則或自動上線程式驅動的大規模上線作業中排除。 若要從這些作業中排除特定執行個體,請將執行個體名稱新增至 [略過執行個體] 清單。 如需大規模上線選項的詳細資訊,請參閱透過 Azure Arc 啟用的 SQL Server 的替代部署選項

警告

無法使用隨用隨付 (PAYG) 的 SQL Server 執行個體。

儲存更新的設定

在確認授權類型、ESU 設定和要排除的任何執行個體之後,請選取 [儲存] 以套用變更。

查詢 SQL Server 設定

您可以使用 Azure Resource Graph 來查詢所選範圍內的 SQL Server 組態設定。 請參閱下列範例。

依授權類型的計數

此範例會傳回依授權類型的計數。

resources
| where type == "microsoft.hybridcompute/machines/extensions"
| where properties.type in ("WindowsAgent.SqlServer","LinuxAgent.SqlServer")
| extend licenseType = iff(properties.settings.LicenseType == '', 'Configuration needed', properties.settings.LicenseType)
| summarize count() by tostring(licenseType)

識別授權類型為未定義的執行個體

此查詢會傳回授權類型為 Null 的執行個體清單。

resources
| where type == "microsoft.hybridcompute/machines/extensions"
| where properties.type in ("WindowsAgent.SqlServer","LinuxAgent.SqlServer")
| where isnull(properties.settings.LicenseType)
| project ['id'], resourceGroup, subscriptionId

列出每個 SQL Server 執行個體的設定詳細資料

此查詢會識別每個執行個體的許多詳細資料,包括授權類型、ESU 設定和啟用的功能。

resources
| where type == "microsoft.hybridcompute/machines"| where properties.detectedProperties.mssqldiscovered == "true"| extend machineIdHasSQLServerDiscovered = id
| project name, machineIdHasSQLServerDiscovered, resourceGroup, subscriptionId
| join kind= leftouter (
    resources
    | where type == "microsoft.hybridcompute/machines/extensions"    | where properties.type in ("WindowsAgent.SqlServer","LinuxAgent.SqlServer")
    | extend machineIdHasSQLServerExtensionInstalled = iff(id contains "/extensions/WindowsAgent.SqlServer" or id contains "/extensions/LinuxAgent.SqlServer", substring(id, 0, indexof(id, "/extensions/")), "")
    | project Extension_State = properties.provisioningState,
    License_Type = properties.settings.LicenseType,
    ESU = iff(notnull(properties.settings.enableExtendedSecurityUpdates), iff(properties.settings.enableExtendedSecurityUpdates == true,"enabled","disabled"), ""),
    Extension_Version = properties.instanceView.typeHandlerVersion,
    Excluded_instances = properties.ExcludedSqlInstances,
    Purview = iff(notnull(properties.settings.ExternalPolicyBasedAuthorization),"enabled",""),
    Entra = iff(notnull(properties.settings.AzureAD),"enabled",""),
    BPA = iff(notnull(properties.settings.AssessmentSettings),"enabled",""),
    machineIdHasSQLServerExtensionInstalled)on $left.machineIdHasSQLServerDiscovered == $right.machineIdHasSQLServerExtensionInstalled
| where isnotempty(machineIdHasSQLServerExtensionInstalled)
| project-away machineIdHasSQLServerDiscovered, machineIdHasSQLServerExtensionInstalled

列出具有 SQL Server 執行個體的已啟用 Arc 的伺服器

此查詢會識別已啟用 Azure Arc 並探索到 SQL Server 執行個體的伺服器。

resources
| where type == "microsoft.hybridcompute/machines"
| where properties.detectedProperties.mssqldiscovered == "true"
//| summarize count()

此查詢會傳回已啟用 Azure Arc 並具有 SQL Server 執行個體,但未安裝 Arc SQL Server 延伸模組的伺服器。 此查詢僅適用於 Windows 伺服器。

resources
| where type == "microsoft.hybridcompute/machines"
| where properties.detectedProperties.mssqldiscovered == "true"
| project machineIdHasSQLServerDiscovered = id
| join kind= leftouter (
    resources
    | where type == "microsoft.hybridcompute/machines/extensions"
    | where properties.type == "WindowsAgent.SqlServer"
    | project machineIdHasSQLServerExtensionInstalled = substring(id, 0, indexof(id, "/extensions/WindowsAgent.SqlServer")))
on $left.machineIdHasSQLServerDiscovered == $right.machineIdHasSQLServerExtensionInstalled
| where isempty(machineIdHasSQLServerExtensionInstalled)
| project machineIdHasSQLServerDiscoveredButNotTheExtension = machineIdHasSQLServerDiscovered

如需 Azure Resource Graph 查詢的更多範例,請參閱入門 Resource Graph 查詢

管理無限制虛擬化

若要啟用無限制虛擬化,Azure Arc 啟用的 SQL Server 支援特殊的資源類型:SQLServerLicense。 此資源可讓您使用已安裝的 SQL Server 執行個體來授權許多虛擬機器。 如需授權模型的詳細資訊,請參閱使用無限制虛擬化來授權 SQL Server 執行個體

必要條件

您的 RBAC 角色包括下列權限:

  • Microsoft。 AzureArcData/SqlLicenses/read
  • Microsoft。 AzureArcData/SqlLicenses/write
  • Microsoft.Management/managementGroups/read
  • Microsoft.Resources/subscriptions/read
  • Microsoft.Resources/subscriptions/resourceGroups/read
  • Microsoft.Support/supporttickets/write

建立 SQL Server 授權

若要建立 SQL Server 授權資源,請使用下列方法之一:

  1. 選取 Azure Arc
  2. 在 [資料服務] 底下選取 [SQL Server 授權]
  3. 按下 [+建立]
  4. 選取 [SQL Server 實體核心授權]
  5. 完成建立精靈

變更 SQL Server 授權屬性

若要變更 SQL Server 授權屬性,例如在稍後啟用它,請使用下列方法之一:

  1. 選取 Azure Arc
  2. 在 [資料服務] 底下選取 [SQL Server 授權]
  3. 按下相關授權
  4. 選取 [管理] 底下的 [設定]
  5. 進行變更,然後按下 [套用]

管理範圍內的資源

您可以按照下列步驟來管理特定 SQL Server 實體核心授權範圍內的資源:

  1. 選取 Azure Arc
  2. 在 [資料服務] 底下選取 [SQL Server 授權]
  3. 按下相關授權
  4. 在 [管理] 底下選取 [範圍中的資源]

如果未將特定資源設定為使用此授權 (套用實體核心授權資料行會顯示「否」),則您可以變更:

  1. 選取清單上的特定資源
  2. 按下 [套用授權] 索引標籤。
  3. 閱讀免責聲明,然後按下 [確認]

列出 SQL Server 授權範圍內啟用了 Arc 的伺服器

此查詢會列出授權範圍內所有啟用了 Azure Arc 的伺服器,以及每個伺服器的相關屬性。

resources
        | where type =~ 'Microsoft.HybridCompute/machines'
        | where ('${scopeType}'!= 'Subscription' or subscriptionId == '${subscription}')
        | where ('${scopeType}' != 'ResourceGroup' or (resourceGroup == '${resourceGroup.toLowerCase()}' and subscriptionId == '${subscription}'))
        | extend status = tostring(properties.status)
        | where status =~ 'Connected'
        | join kind = leftouter
        (
        resources
        | where type =~ 'Microsoft.HybridCompute/machines/extensions'
        | where name == 'WindowsAgent.SqlServer' or name == 'LinuxAgent.SqlServer'
        | extend machineId = substring(id, 0, indexof(id, '/extensions'))
        | extend extensionId = id
        )
        on $left.id == $right.machineId
        | where isnotnull(extensionId)
        | project id, name, properties.status, resourceGroup, subscriptionId, Model = properties.detectedProperties.model, Manufacturer = properties.detectedProperties.manufacturer, kind, OSE = properties.osName, License_applied = properties1.settings.UsePhysicalCoreLicense.IsApplied
        |order by name asc