你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
虚拟机规模集可与 Azure 期望状态配置 (DSC) 扩展处理程序配合使用。 虚拟机规模集提供部署和管理大量虚拟机的方法,并且可根据负载情况实现弹性横向缩减和扩展。 VM 联机时,DSC 用于配置 VM,使它们能够运行生产软件。
注释
DSC 扩展将于 2028 年 3 月 31 日停用。 请在该日期前过渡到 Azure 机器配置。 有关详细信息,请参阅博客文章公告。 Azure 计算机配置服务结合了 DSC 扩展、Azure Automation State Configuration 的某些功能,以及客户反馈中通常请求的功能。 Azure Machine Configuration 还包括通过已启用 Arc 的服务器提供的混合计算机支持。
部署到虚拟机和部署到虚拟机规模集之间的区别
虚拟机规模集的基础模板结构与单一 VM 略有不同。 具体而言,单一 VM 是在“virtualMachines”节点下扩展部署。 其中有一个 "type": "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 添加在“extensions”下面
"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 会重新启动,然后再上线。 VM 联机后,将下载 DSC 配置 .zip 文件,并在 VM 上预配该文件。 在 Azure DSC 扩展概述中可以找到详细信息。
后续步骤
了解DSC 扩展安全处理凭据的方法。
有关 Azure DSC 扩展处理程序的详细信息,请参阅 Introduction to the Azure Desired State Configuration extension handler(Azure Desired State Configuration 扩展处理程序简介)。
有关 PowerShell DSC 的详细信息,请访问 PowerShell 文档中心。