我想为基于ARM模板的VM部署禁用"Windows更新"。我在最近的Microsoft.Compute提供程序架构中找到了一个相关的设置enableAutomaticUpdates
。但我没有找到任何使用此设置的ARM模板。我搜索了几个与Windows虚拟机部署相关的Azure Quickstart模板,但它们都不打算在设置时控制Windows Update服务的行为。我知道CLASSIC部署模型有可用的选项,但我明确地在寻找使用Azure资源管理器部署模型的解决方案。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
...
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('vmLocation')]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('vmStorageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
...
我试图在现有ARM模板中使用属性windowsConfiguration
,导致部署失败,并显示此错误消息(显示在Azure门户中)。
在类型为的对象上找不到成员"windowsConfiguration"属性"。路径"properties.windowsConfiguration",第1行,位置259.(代码:BadRequest)
当我将Microsoft.Compute升级到版本2015-08-01,尝试引用包含配置属性enableAutomaticUpdates
的架构时,VM部署失败,并显示此错误消息。显然我做错了什么。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
...
{
"apiVersion": "2015-08-01",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('vmLocation')]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('vmStorageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
...
找不到位置"西欧"和的注册资源提供商API版本"2015-08-01",适用于类型"虚拟机"。支持的api版本为"2015-05-01预览,2015-06-15,2016-03-30"。这个支持的位置为"eastus"、"eastus2"、"westus"、"centralus",中北部、中南部、北欧、西欧、东亚,东南亚、日本东部、日本西部、澳大利亚东部,澳大利亚东南部,巴西南部。(代码:NoRegisteredProviderFound)
我正在寻求一些指导,如何编写使用Azure计算提供程序架构版本2015-08-01的ARM模板,以在设置时禁用Windows更新。我的.NET解决方案使用Azure SDK 2.7.1。
我非常接近这个解决方案。我只是误解了模式。根据模式的这一部分,windowsConfiguration
是osProfile
的一部分。如果ARM模板是这样写的,Azure资源管理器了解我想要什么,并在设置时禁用自动更新。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
...
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('vmStorageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"enableAutomaticUpdates": false
}
},
...
Azure门户中令人难以置信的工具资源管理器显示了给定资源的当前配置。如您所见,EnableAutomaticUpdates
设置为false。
{
"properties": {
"vmId": "10400cdd-26be-4be4-99d8-2d5c22d96911",
"hardwareProfile": {
"vmSize": "Standard_D2"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2012-R2-Datacenter",
"version": "latest"
},
"osDisk": {
"osType": "Windows",
"name": "osdisk",
"createOption": "FromImage",
"vhd": {
"uri": "this_is_not_for_public_use"
},
"caching": "ReadWrite"
},
"dataDisks": []
},
"osProfile": {
"computerName": "this_is_not_for_public_use",
"adminUsername": "this_is_not_for_public_use",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": false
},
"secrets": []
},
"networkProfile": {
"networkInterfaces": [
{
"id": "this_is_not_for_public_use/providers/Microsoft.Network/networkInterfaces/ComputeNode15-Nic"
}
]
},
"provisioningState": "Creating"
},
"id": "this_is_not_for_public_use/providers/Microsoft.Compute/virtualMachines/this_is_not_for_public_use",
"name": "this_is_not_for_public_use",
"type": "Microsoft.Compute/virtualMachines",
"location": "westeurope",
"tags": {
"displayName": "VirtualMachine"
}
}
我更改了模板以使用资源组的位置——在大多数情况下这是一个有用的选项。感谢Martyn C提供的提示和宝贵的反馈,将我推向了正确的方向。
查看上面的错误消息,您将位置传递为"西欧",而它应该是"西欧"。区域名称应全部小写。
您可以使用JSON模板"location": "[resourceGroup().location]"
中的以下行来使用资源组的位置,这将是更好的做法。