配置已启用 Azure Arc 的 SQL Server
适用范围:SQL Server
每个已启用 Azure Arc 的服务器都包含一组应用于该服务器中安装的所有 SQL Server 实例的属性。 在计算机上安装 SQL Server 的 Azure 扩展后,可以配置这些属性。 但只有安装了一个或多个 SQL Server 实例时,这些属性才会生效。 在 Azure 门户中,已启用 Azure Arc 的 SQL Server 的“概述”页面介绍了 SQL Server 配置对特定实例产生的影响。
先决条件
对于将在其中注册 SQL Server 实例的资源组,你拥有参与者角色。 有关详细信息,请参阅托管的 Azure 资源组。
在用于 SQL Server 即用即付计费的每个订阅中都注册了
Microsoft.AzureArcData
和Microsoft.HybridCompute
资源提供程序。
注册资源提供程序
若要注册资源提供程序,请使用以下方法之一:
- 选择订阅
- 选择自己的订阅
- 在“设置”下,选择“资源提供程序”
- 搜索
Microsoft.AzureArcData
和Microsoft.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 配置”,如下所示。
或
打开已启用 Arc 的 SQL Server 概述页,然后选择“属性”。 在“SQL Server 配置”下,选择需要修改的设置:
- 许可证类型
- ESU 订阅
- 自动更新
设置许可证类型属性
选择一种许可证类型。 有关说明,请参阅许可证类型。
使用物理核心许可证
如果你要配置虚拟机,并且利用无限虚拟化权益来许可 SQL Server 软件或 SQL 订阅,则请选中此复选框。 它将把主机配置属性 UsePhysicalCoreLicense
设置为 True
。 如果选中,P 核心许可证将优先使用,且 SQL Server 软件费用将为 null。
重要
如果物理核心许可证配置了即用即付计费计划,则所选“许可证类型”应设置为“即用即付”。 这不会在虚拟机级别触发额外费用,但会在 P 核心许可证取消激活或删除的情况下确保许可和计费不中断。
订阅扩展安全更新
本部分允许订阅单个主机的扩展安全更新 (ESU)。 若要获得 ESU 订阅资格,主机必须将“许可证类型”设置为“即用即付”或“具有软件保障的许可证”。 通过此选项,可在主机是虚拟机时使用 vCPU(v 核心)进行订阅,或者在主机是不使用虚拟机运行的物理服务器时使用物理核心进行订阅。
选择“订阅扩展安全更新程序”。 它将把主机配置属性 EnabelExtendedSecurityUpdates
设置为 True
。 单击“保存”后,将激活订阅。
有关 ESU 许可选项的详细信息,请参阅在生产环境中订阅扩展安全更新程序。
注意
- 与 p 核心 ESU 许可证不同,在为主机订阅 ESU 时,无需定义每台计算机的可计费核心数量。 适用于 SQL Server 的 Azure 扩展会检测主机的大小和类型(虚拟或物理)、SQL Server 版本,并按这些参数计费。
- 启用 ESU 后,则在取消 ESU 订阅之前,主机的“许可证类型”无法更改为“仅限许可证”。
使用物理核心 ESU 许可证
如果你要配置虚拟机,并且利用无限制虚拟化权益来启用 ESU 订阅,则请选中此复选框。 它将把 UseEsuPhysicalCoreLicense
设置为 true
。 如果选中,P 核心许可证将优先使用,且虚拟机级别的 SQL Server ESU 费用将为 null。
取消订阅扩展安全更新程序
可以随时取消 Azure Arc 启用的扩展安全更新程序。 取消后会立即停止 ESU 费用。 选择“取消订阅扩展安全更新程序”。 单击“保存”后,将终止订阅。
添加到“排除的实例”列表
可以从 Azure 策略驱动的大规模加入操作或自动加入流程中排除某些实例。 要从这些操作中排除特定实例,请将实例名称添加到“跳过实例”列表中。 有关大规模加入选项的详细信息,请参阅已启用 Azure Arc 的 SQL Server 的备用部署选项。
注意
不能排除使用即用即付 (PAYG) 付费模式的 SQL Server 实例。
保存更新的配置
验证许可证类型、ESU 设置以及要排除的任何实例后,选择“保存”以应用更改。
重要
所列提供程序的基础结构不支持 SQL Server 软件或 SQL Server ESU 订阅的无限制虚拟化权益。 如果在所列提供程序的虚拟机中运行 SQL Server并选择此选项,则你的意图将被忽略,并且需要为虚拟机的 V 核心付费。 有关详细信息,请参阅列出的提供程序。
使用 Azure Policy 大规模订阅扩展安全更新
可以使用名为将符合条件的启用Arc的SQL Server实例订阅到扩展安全更新 Azure Policy 定义在多台启用 Arc 的计算机上激活 ESU 订阅。 将此策略定义分配给所选范围时,其会在安装了适用于 SQL Server 的 Azure 扩展的所有已启用 Arc 的计算机上启用 ESU。 如果其中任一计算机具有合格的 SQL Server 实例,ESU 订阅将立即激活。
按照以下步骤激活该策略:
- 导航到 Azure 门户中的“Azure Policy”,然后选择“定义”。
- 搜索将符合条件的启用Arc的SQL Server实例订阅到扩展安全更新,然后右键单击策略。
- 选择“分配策略”。
- 选择订阅和资源组(可选)作为作用域。
- 确保“策略实施”设置为“已启用”。
- 在“参数”选项卡上,将“启用扩展安全更新”的值设置为“True”。
- 在“修正”选项卡上:
- 选择“创建修正任务”以将该策略应用到现有的资源。 如果未选择,该策略将仅应用到新创建的资源。
- 选择“创建托管标识”,然后选择“系统分配的托管标识”(推荐)或“用户分配的托管标识”,后者具有“用于 SQL Server 部署的 Azure 扩展”和“读者”权限。
- 选择标识的位置。
- 选择“查看 + 创建” 。
- 选择“创建”。
查询 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 查询示例。
列出已订阅 ESU 的已启用 Arc 的 SQL Server 实例
以下示例介绍如何查看所有合格 SQL Server 2012 (11.x) 或 SQL Server 2014 (12.x) 实例及其 ESU 订阅状态。
resources
| where type == 'microsoft.azurearcdata/sqlserverinstances'
| extend Version = properties.version
| extend Edition = properties.edition
| extend containerId = tolower(tostring (properties.containerResourceId))
| where Version in ("2012", "2014")
| where Edition in ("Enterprise", "Standard")
| where isnotempty(containerId)
| project containerId, SQL_instance = name, Version, Edition
| join kind=inner (
resources
| where type == "microsoft.hybridcompute/machines"
| extend machineId = tolower(tostring(id))
| project machineId, Machine_name = name
)
on $left.containerId == $right.machineId
| join kind=inner (
resources
| where type == "microsoft.hybridcompute/machines/extensions"
| where properties.type in ("WindowsAgent.SqlServer","LinuxAgent.SqlServer")
| extend machineIdHasSQLServerExtensionInstalled = tolower(iff(id contains "/extensions/WindowsAgent.SqlServer" or id contains "/extensions/LinuxAgent.SqlServer", substring(id, 0, indexof(id, "/extensions/")), ""))
| project machineIdHasSQLServerExtensionInstalled, 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
)
on $left.machineId == $right.machineIdHasSQLServerExtensionInstalled
| project-away machineId, containerId, machineIdHasSQLServerExtensionInstalled
列出托管可计费 SQL Server 实例的已启用 Arc 的服务器
此查询可识别托管可计费或需要 SQL Server 软件许可证的 SQL Server 实例的计算机(虚拟或物理)。 它提供 SQL Server 配置的详细信息,包括许可证类型、ESU 设置、V 核心或 P 核心大小和其他相关参数。
resources
| where type =~ 'Microsoft.HybridCompute/machines'
| extend status = tostring(properties.status)
| where status =~ 'Connected'
| extend machineID = tolower(id)
| extend VMbyManufacturer = toboolean(iff(properties.detectedProperties.manufacturer in (
"VMware",
"QEMU",
"Amazon EC2",
"OpenStack",
"Hetzner",
"Mission Critical Cloud",
"DigitalOcean",
"UpCloud",
"oVirt",
"Alibaba",
"KubeVirt",
"Parallels",
"XEN"
), 1, 0))
| extend VMbyModel = toboolean(iff(properties.detectedProperties.model in (
"OpenStack",
"Droplet",
"oVirt",
"Hypervisor",
"Virtual",
"BHYVE",
"KVM"
), 1, 0))
| extend GoogleVM = toboolean(iff((properties.detectedProperties.manufacturer =~ "Google") and (properties.detectedProperties.model =~ "Google Compute Engine"), 1, 0))
| extend NutanixVM = toboolean(iff((properties.detectedProperties.manufacturer =~ "Nutanix") and (properties.detectedProperties.model =~ "AHV"), 1, 0))
| extend MicrosoftVM = toboolean(iff((properties.detectedProperties.manufacturer =~ "Microsoft Corporation") and (properties.detectedProperties.model =~ "Virtual Machine"), 1, 0))
| extend billableCores = iff(VMbyManufacturer or VMbyModel or GoogleVM or NutanixVM or MicrosoftVM, properties.detectedProperties.logicalCoreCount, properties.detectedProperties.coreCount)
| join kind = leftouter // Join Extension
(
resources
| where type =~ 'Microsoft.HybridCompute/machines/extensions'
| where name == 'WindowsAgent.SqlServer' or name == 'LinuxAgent.SqlServer'
| extend extMachineID = substring(id, 0, indexof(id, '/extensions'))
| extend extensionId = id
)
on $left.id == $right.extMachineID
| join kind = inner // Join SQL Arc
(
resources
| where type =~ 'microsoft.azurearcdata/sqlserverinstances'
| extend sqlVersion = tostring(properties.version)
| extend sqlEdition = tostring(properties.edition)
| extend is_Enterprise = toint(iff(sqlEdition == "Enterprise", 1, 0))
| extend sqlStatus = tostring(properties.status)
| extend licenseType = tostring(properties.licenseType)
| where sqlEdition in ('Enterprise', 'Standard')
| where licenseType !~ 'HADR'
| where sqlStatus =~ "Connected"
| extend ArcServer = tolower(tostring(properties.containerResourceId))
| order by sqlEdition
)
on $left.machineID == $right.ArcServer
| where isnotnull(extensionId)
| summarize Edition = iff(sum(is_Enterprise) > 0, "Enterprise", "Standard") by machineID
, name
, resourceGroup
, subscriptionId
, Model = tostring(properties.detectedProperties.model)
, Manufacturer = tostring(properties.detectedProperties.manufacturer)
, License_Type = tostring(properties1.settings.LicenseType)
, OS = tostring(properties.osName)
, Uses_UV = tostring(properties1.settings.UsePhysicalCoreLicense.IsApplied)
, Cores = tostring(billableCores)
, Version = sqlVersion
| project-away machineID
| order by Edition, name asc
管理 SQL Server 的无限制虚拟化权益
为启用无限制虚拟化,由 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 许可证资源,请使用以下方法之一:
- 选择“Azure Arc”
- 在“数据服务”下,选择“SQL Server 许可证”
- 选择“+创建”。
- 选择“SQL Server 物理核心许可证”
- 完成创建向导
更新 SQL Server 许可证资源
要更改 SQL Server 许可证属性,例如在以后激活它,请使用以下方法之一:
- 选择“Azure Arc”
- 在“数据服务”下,选择“SQL Server 许可证”
- 选择有问题的许可证
- 选择“管理”下的“配置”
- 进行更改,然后选择“应用”
管理 P 核心许可证范围内的资源
你可以使用以下步骤管理特定 SQL Server 物理核心许可证范围内的资源:
- 选择“Azure Arc”
- 在“数据服务”下,选择“SQL Server 许可证”
- 选择有问题的许可证
- 在“管理”下选择“范围中的资源”
如果未将特定资源配置为使用此许可证(“应用物理核心许可证”列显示“否”),则可以更改:
- 在列表上选择特定资源
- 选择“应用许可证”选项卡
- 阅读免责声明并选择“确认”
列出 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
管理 SQL Server ESU 订阅的无限制虚拟化权益
要启用 ESU 订阅的无限制虚拟化,由 Azure Arc 启用的 SQL Server 应支持特殊的资源类型:SQLServerEsuLicense。 通过此资源,你可以为一组物理主机启用 ESU 订阅,在这些物理主机上运行不支持的 SQL Server 实例的虚拟机数量不受限制。 有关许可模型的详细信息,请参阅订阅 SQL Server ESU(按具有无限制虚拟化的物理核心列出)。
先决条件
你的 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 ESU 许可证资源
要创建 SQL Server ESU 许可证资源,请使用以下方法之一:
- 选择“Azure Arc”
- 在“数据服务”下,选择“SQL Server ESU 许可证”
- 选择“+创建”。
- 完成创建向导
更新 SQL Server ESU 许可证资源
要更改 SQL Server ESU 许可证属性,例如终止订阅,请使用以下方法之一:
- 选择“Azure Arc”
- 在“数据服务”下,选择“SQL Server ESU 许可证”
- 选择有问题的许可证
- 选择“管理”下的“配置”
- 进行更改,然后选择“应用”
管理 ESU P 核心许可证范围内的资源
你可以使用以下步骤管理特定 SQL Server ESU 许可证范围内的资源:
- 选择“Azure Arc”
- 在“数据服务”下,选择“SQL Server ESU 许可证”
- 选择有问题的许可证
- 在“管理”下选择“范围中的资源”
此视图将仅显示范围内已连接的计算机,这些计算机托管的是服务中断的 SQL Server 实例,其版本与你在管理的 P 核心 ESU 许可证版本相匹配。 如果未将特定资源配置为使用此许可证(“已应用物理核心许可证”列显示“否”),则可以更改:
- 在列表上选择特定资源
- 选择“订阅 ESU”选项卡以订阅或选择“取消订阅 ESU”以取消订阅。
- 阅读免责声明并选择“确认”
列出 SQL Server ESU 许可证范围内已启用 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.UseEsuPhysicalCoreLicense.IsApplied
|order by name asc