1.首先下载CLI2.0,可以搜索到官方下载

2.安装后打开powershell或者“运行”,输入“cmd”进入命令行,输入“az”会出现欢迎页面

C:\Users\JOSE>az

Welcome to Azure CLI!
---------------------
Use `az -h` to see available commands or go to https://aka.ms/cli.

Telemetry
---------
The Azure CLI collects usage data in order to improve your experience.
The data is anonymous and does not include commandline argument values.
The data is collected by Microsoft.

You can change your telemetry settings with `az configure`.


     /\
    /  \    _____   _ _  ___ _
   / /\ \  |_  / | | | \'__/ _\
  / ____ \  / /| |_| | | |  __/
 /_/    \_\/___|\__,_|_|  \___|


Welcome to the cool new Azure CLI!
3.输入az login 登陆,弹出网页登陆,成功后显示订阅信息

    C:\Users\JOSE>az login
    Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code"
    You have logged in. Now let us find all subscriptions you have access to...
    [
      {
        "cloudName""AzureCloud",
        "id""6a4398cd-e676-49f0-81a6-47128b9cb56a",
        "isDefault"true,
        "name""Pay-As-You-Go",
        "state""Enabled",
        "tenantId""67f536b2-f7fb-4286-a42d-5fcd2d717d7e",
        "user": {
          "name""xxx",
          "type""user"
        }
      },
      {
        "cloudName""AzureCloud",
        "id""5e13e2a0-d432-497b-9ce1-0cf16ff1b67e",
        "isDefault"false,
        "name""Azure for Students Starter",
        "state""Enabled",
        "tenantId""67f536b2-f7fb-4286-a42d-5fcd2d717d7e",
        "user": {
          "name""xxx",
          "type""user"
        }
      }
    ]

4.输入az disk list 会显示你的资源列表
5.关闭虚拟机
az vm stop -n Debian7 -g VM
-n 后填自己的VM名字 -g后是所在资源组名字(下同)
6.更换虚拟机的系统磁盘
az vm update -g VM -n Debian7 --os-disk /subscriptions/6a4398cd-e676-49f0-81a6-47128b9cb56a/resourceGroups/VM/providers/Microsoft.Compute/disks/hhd50Gstandard
–os-disk后面是要迁移的磁盘的ID
如果成功会显示一大串

{
  "availabilitySet"null,
  "diagnosticsProfile": {
    "bootDiagnostics": {
      "enabled"true,
      "storageUri""https://gxmhm.blob.core.windows.net/"
    }
  },
  "hardwareProfile": {
    "vmSize""Standard_B1s"
  },
  "id""/subscriptions/6a4398cd-e676-49f0-81a6-47128b9cb56a/resourceGroups/VM/providers/Microsoft.Compute/virtualMachines/Debian7",
  "identity"null,
  "instanceView"null,
  "licenseType"null,
  "location""centralus",
  "name""Debian7",
  "networkProfile": {
    "networkInterfaces": [
      {
        "id""/subscriptions/6a4398cd-e676-49f0-81a6-47128b9cb56a/resourceGroups/VM/providers/Microsoft.Network/networkInterfaces/debian715",
        "primary"null,
        "resourceGroup""VM"
      }
    ]
  },
  "osProfile": {
    "adminPassword"null,
    "adminUsername""gxmhm",
    "computerName""Debian7",
    "customData"null,
    "linuxConfiguration": {
      "disablePasswordAuthentication"true,
      "ssh": {
        "publicKeys": [
          {
            "keyData""ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAvCJk3Gsy8ncUIlq3vIgsCE/F58nZBDz6JnFZ23hW/AZDjyf1cpJKdxbKCcCAkpCJtYU4hYyPkzAD+HB0UPRNWhKcsXl9UozG8OF/E8xqw9Dg6o/ovyDfivlNHagJyGojShGL4QlxLY042veCAYC8y/5xCHyGTkzD8yqyR12vpd5RrWE8Dz/9fQbRJDe1CCDs/6he4qzG6AUUilnhj8KPCK3bfqz5G2tdiciEQZ7d2AoKZqb5q4hdILmfOifL+gqS55dGQBYVQE4+RwBWnxP86kvyMRBZLBj8AGzaLb0iyvCGTPTpTiql2ON2Vu/Npw7E56StYGQfz9SNR5pfRkMUQw==",
            "path""/home/gxmhm/.ssh/authorized_keys"
          }
        ]
      }
    },
    "secrets": [],
    "windowsConfiguration"null
  },
  "plan"null,
  "provisioningState""Succeeded",
  "resourceGroup""VM",
  "resources"null,
  "storageProfile": {
    "dataDisks": [],
    "imageReference": {
      "id"null,
      "offer""Debian",
      "publisher""credativ",
      "sku""7",
      "version""latest"
    },
    "osDisk": {
      "caching""ReadWrite",
      "createOption""FromImage",
      "diskSizeGb"50,
      "encryptionSettings"null,
      "image"null,
      "managedDisk": {
        "id""/subscriptions/6a4398cd-e676-49f0-81a6-47128b9cb56a/resourceGroups/VM/providers/Microsoft.Compute/disks/hhd50Gstandard",
        "resourceGroup""VM",
        "storageAccountType""Standard_LRS"
      },
      "name""hhd50Gstandard",
      "osType""Linux",
      "vhd"null,
      "writeAcceleratorEnabled"null
    }
  },
  "tags"null,
  "type""Microsoft.Compute/virtualMachines",
  "vmId""6a1f98c2-d36d-4b6b-9b85-2393f410a138",
  "zones"null
}

无特殊说明,本站文章均为原创,转载请注明出处。
本文首发于微信公众号“我的探索”ID:MyExploration

觉得不错,支持一下服务器费用


最后修改日期:2018-08-05

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。

4 × 1 =