0

我想更改我的虚拟机大小。

在此处输入图像描述

4

1 回答 1

1

修改现有 VM 大小的 ARM 模板片段:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "virtualMachine_name": {
            "defaultValue": "myvm",
            "type": "String"
        },
        "disk_OS_externalid": {
            "defaultValue": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxxx-xxxxx/providers/Microsoft.Compute/disks/myvm_OsDisk_1_4db7cb0985634db6b86e93392286c2ac",
            "type": "String"
        },
        "networkInterface_externalid": {
            "defaultValue": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxxx-xxxxx/providers/Microsoft.Network/networkInterfaces/myvm345",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2021-03-01",
            "name": "[parameters('virtualMachine_name')]",
            "location": "westus2",
            "zones": [
                "1"
            ],
            "identity": {
                "type": "UserAssigned",
                "userAssignedIdentities": {
                    "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/AzSecPackAutoConfigRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/AzSecPackAutoConfigUA-westus2": {
                        "principalId": "6ccdb9b1-6cce-4a62-qazx-e814d59f3365",
                        "clientId": "9ad4fcb5-9485-4951-qgsa-654f64039941"
                    }
                }
            },
            "properties": {
                "hardwareProfile": {
                    "vmSize": "Standard_B1s"
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "MicrosoftWindowsDesktop",
                        "offer": "Windows-10",
                        "sku": "20h2-pro",
                        "version": "latest"
                    },
                    "osDisk": {
                        "osType": "Windows",
                        "name": "[concat(parameters('virtualMachine_name'), '_OsDisk_1_4db7cb0985634db6b86e93392286c2ac')]",
                        "createOption": "FromImage",
                        "caching": "ReadWrite",
                        "managedDisk": {
                            "storageAccountType": "Premium_LRS",
                            "id": "[parameters('disk_OS_externalid')]"
                        },
                        "diskSizeGB": 127
                    },
                    "dataDisks": []
                },
                "osProfile": {
                    "computerName": "[parameters('virtualMachine_name')]",
                    "adminUsername": "azureuser",
                    "windowsConfiguration": {
                        "provisionVMAgent": true,
                        "enableAutomaticUpdates": true,
                        "patchSettings": {
                            "patchMode": "AutomaticByOS",
                            "assessmentMode": "ImageDefault",
                            "enableHotpatching": false
                        }
                    },
                    "secrets": [],
                    "allowExtensionOperations": true,
                    "requireGuestProvisionSignal": true
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[parameters('networkInterface_externalid')]"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true
                    }
                },
                "licenseType": "Windows_Client"
            }
        }
    ]
}

这是一个Azure 示例,您可以使用较新的资源管理(预览)库进行调整以执行相同操作。

于 2021-09-04T09:47:54.593 回答