虚拟机规模集 可与 Azure Desired State Configuration (DSC) 扩展处理程序一起使用。 虚拟机规模集提供了部署和管理大量虚拟机的方法,并且可以根据负载弹性扩展和缩减。 DSC 用于在 VM 联机时配置 VM,以便运行生产软件。
注释
DSC 扩展将于 2028 年 3 月 31 日停止使用。 请在该日期前迁移到 Azure 机器配置。 有关详细信息,请参阅博客文章公告。 Azure 计算机配置服务结合了 DSC 扩展、Azure Automation State Configuration 的某些功能,以及客户反馈中通常请求的功能。 Azure Machine Configuration 还包括通过已启用 Arc 的服务器提供的混合计算机支持。
部署到虚拟机和虚拟机规模集之间的差异
虚拟机规模集的基础模板结构与单个 VM 略有不同。 具体而言,单个 VM 在“virtualMachines”节点下部署扩展。 有一个类型为“extensions”的条目,其中 DSC 被添加到模板中。
"resources": [
{
"name": "Microsoft.Powershell.DSC",
"type": "extensions",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"tags": {
"displayName": "dscExtension"
},
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.20",
"autoUpgradeMinorVersion": false,
"forceUpdateTag": "[parameters('dscExtensionUpdateTagVersion')]",
"settings": {
"configuration": {
"url": "[concat(parameters('_artifactsLocation'), '/', variables('dscExtensionArchiveFolder'), '/', variables('dscExtensionArchiveFileName'))]",
"script": "DscExtension.ps1",
"function": "Main"
},
"configurationArguments": {
"nodeName": "[variables('vmName')]"
}
},
"protectedSettings": {
"configurationUrlSasToken": "[parameters('_artifactsLocationSasToken')]"
}
}
}
]
虚拟机规模集节点具有“properties”部分,其中包含“VirtualMachineProfile”、“extensionProfile”属性。 DSC 在“扩展”下添加
"extensionProfile": {
"extensions": [
{
"name": "Microsoft.Powershell.DSC",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.20",
"autoUpgradeMinorVersion": false,
"forceUpdateTag": "[parameters('DscExtensionUpdateTagVersion')]",
"settings": {
"configuration": {
"url": "[concat(parameters('_artifactsLocation'), '/', variables('DscExtensionArchiveFolder'), '/', variables('DscExtensionArchiveFileName'))]",
"script": "DscExtension.ps1",
"function": "Main"
},
"configurationArguments": {
"nodeName": "localhost"
}
},
"protectedSettings": {
"configurationUrlSasToken": "[parameters('_artifactsLocationSasToken')]"
}
}
}
]
虚拟机规模集的行为
虚拟机规模集的行为与单个 VM 的行为相同。 创建新的 VM 时,会自动使用 DSC 扩展对其进行预配。 如果扩展需要较新版本的 WMF,VM 将在联机之前重新启动。 联机后,它会下载 DSC 配置 .zip 并在 VM 上预配它。 可以在 Azure DSC 扩展概述中找到更多详细信息。
后续步骤
了解 DSC 扩展如何安全地处理凭据。
有关 Azure DSC 扩展处理程序的详细信息,请参阅 Azure Desired State Configuration 扩展处理程序简介。
有关 PowerShell DSC 的详细信息, 请访问 PowerShell 文档中心。