Azure Managed Disk操作
Azure Managed Disk对原有的Page Blob进行了一次封装。使得Azure VM的Disk操作变得非常简单。本文将介绍实际操作中针对Manage Disk的一些操作。
一、创建Manage Disk
Manage Disk的创建,可以创建空磁盘,也可以从其他源创建Disk。
1 创建空磁盘
root@hw-surfacebook:~# az disk create -g hwtest -n hwempty01 --size-gb --sku Standard_LRS
{\ Finished ..
"accountType": "Standard_LRS",
"creationData": {
"createOption": "Empty",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": null,
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/hwempty01",
"location": "chinanorth",
"name": "hwempty01",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-12T09:39:57.982040+00:00",
"type": "Microsoft.Compute/disks"
}
2 从其他源创建磁盘
可以通过存储账户中Page Blob创建Disk:
root@hw-surfacebook:~# az disk create -g hwfdsk -n hwmd01 --source https://h2portalvhdsn6t2ktgjscst.blob.core.chinacloudapi.cn/vhds/hwfdsk-hwfdsk-2017-06-23.vhd
{/ Finished ..
"accountType": "Premium_LRS",
"creationData": {
"createOption": "Import",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "https://h2portalvhdsn6t2ktgjscst.blob.core.chinacloudapi.cn/vhds/hwfdsk-hwfdsk-2017-06-23.vhd",
"storageAccountId": null
},
"diskSizeGb": null,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwfdsk/providers/Microsoft.Compute/disks/hwmd01",
"location": "chinanorth",
"name": "hwmd01",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwfdsk",
"tags": {},
"timeCreated": "2017-06-23T14:52:46.629909+00:00",
"type": "Microsoft.Compute/disks"
}
二 复制Disk
Managed Disk的复制就是用Create的命令来实现的:
root@hw-surfacebook:~# az disk create -g hwtest -n mydisk03 --source mydisk02
{\ Finished ..
"accountType": "Premium_LRS",
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk02",
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk03",
"location": "chinanorth",
"name": "mydisk03",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-12T09:48:33.620377+00:00",
"type": "Microsoft.Compute/disks"
}
命令是把mydisk02复制到mydisk03。一般情况下,不指定managed disk的sku,都是Premium_LRS的。
3 跨Resource Group创建managed Disk:
root@hw-surfacebook:~# az disk create -g hwtest -n mydisk04 --source /subscriptions/xxxx/resourceGroups/HWFDSK/providers/Microsoft.Compute/disks/hwmd01
{/ Finished ..
"accountType": "Premium_LRS",
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "/subscriptions/xxxx/resourceGroups/HWFDSK/providers/Microsoft.Compute/disks/hwmd01",
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk04",
"location": "chinanorth",
"name": "mydisk04",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-12T10:01:17.520376+00:00",
"type": "Microsoft.Compute/disks"
}
三 下载Managed Disk
如果想把Managed Disk下载下来,需要通过开放managed Disk的SAS访问权限。具体命令如下:
root@hw-surfacebook:~# az disk grant-access -g hwtest -n mydisk03 --duration-in-seconds
{/ Finished ..
"accessSas": "https://md-xplvtgf1jcgg.blob.core.chinacloudapi.cn/ttq410wsfkk5/abcd?sv=2016-05-31&sr=b&si=31fc2e57-dcd6-4cf1-ba2a-33fb44d560a4&sig=j2JwhG8Gx51sVwOdm%2BNIPEOfTAWiZsoW82XpEjTcAHA%3D"
}
这种情况下,已经Attach到VM的Disk是不能开机的。如果开放了SAS的访问权限,又需要开机,需要把这个权限取消掉。具体命令如下:
root@hw-surfacebook:~# az disk revoke-access -g hwtest -n mydisk03
{/ Finished ..
"endTime": "2017-07-12T09:56:37.555156+00:00",
"error": null,
"name": "acdf95b5-d658-4a17-b680-31f48c8b8927",
"startTime": "2017-07-12T09:56:37.336370+00:00",
"status": "Succeeded"
}
四 更改managed Disk的sku
前面提到过,managed disk在不指定sku的情况下,默认都是SSD的。如果需要转换成HDD的Disk,命令如下:
root@hw-surfacebook:~# az disk update -g hwtest -n mydisk03 --sku Standard_LRS
{
"accountType": "Standard_LRS",
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk02",
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk03",
"location": "chinanorth",
"name": "mydisk03",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-12T09:48:33.620377+00:00",
"type": "Microsoft.Compute/disks"
}
或者在创建的时候就指定SKU:
root@hw-surfacebook:~# az disk create -g hwtest -n mydisk05 --source mydisk04 --sku Standard_LRS
{/ Finished ..
"accountType": "Standard_LRS",
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk04",
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk05",
"location": "chinanorth",
"name": "mydisk05",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-12T10:03:20.170081+00:00",
"type": "Microsoft.Compute/disks"
}
五 对managed disk做snapshot
root@hw-surfacebook:~# az snapshot create -g hwtest -n hwsnapshot01 --source mydisk01
{/ Finished ..
"accountType": "Standard_LRS",
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk01",
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/snapshots/hwsnapshot01",
"location": "chinanorth",
"name": "hwsnapshot01",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-13T05:31:54.692171+00:00",
"type": "Microsoft.Compute/snapshots"
}
从Snapshot创建Disk:
root@hw-surfacebook:~# az disk create -g hwtest -n mydisk06 --source hwsnapshot01
{- Finished ..
"accountType": "Premium_LRS",
"creationData": {
"createOption": "Copy",
"imageReference": null,
"sourceResourceId": null,
"sourceUri": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/snapshots/hwsnapshot01",
"storageAccountId": null
},
"diskSizeGb": ,
"encryptionSettings": null,
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/disks/mydisk06",
"location": "chinanorth",
"name": "mydisk06",
"osType": null,
"ownerId": null,
"provisioningState": "Succeeded",
"resourceGroup": "hwtest",
"tags": {},
"timeCreated": "2017-07-13T05:33:57.468651+00:00",
"type": "Microsoft.Compute/disks"
}
五 用已有的managed disk创建VM
有了managed disk,创建VM就非常简单了,用Azure Cli创建的命令如下:
root@hw-surfacebook:~# az vm create -g hwtest -n hwtest06 --attach-os-disk mydisk06 --vnet-name hwtest --subnet Subnet- --os-type Linux
{- Finished ..
"fqdns": "",
"id": "/subscriptions/xxxx/resourceGroups/hwtest/providers/Microsoft.Compute/virtualMachines/hwtest06",
"location": "chinanorth",
"macAddress": "00-17-FA-00-C7-FA",
"powerState": "VM running",
"privateIpAddress": "10.3.0.5",
"publicIpAddress": "139.219.104.221",
"resourceGroup": "hwtest"
}
总结:
有了managed Disk,很多针对VM Disk的操作变得简单很多。
Azure Managed Disk操作的更多相关文章
- Azure Managed Disk
Azure的磁盘存储是保存在存储账户中的Page Blob.由于Azure Storage Account的各种限制,在设计VM的磁盘存储时,要符合Azure磁盘存储账户的最佳实践,请参考:http: ...
- 把ASM下的HDD VM转换成ARM下Managed Disk的SSD VM
在ASM下,要把HDD的VM转换成SSD的VM步骤非常复杂.需要手工把Disk从普通存储账户复制到高级存储账户.再通过这个Disk创建VM. 目前在有了ASM到ARM的迁移工具,以及Managed D ...
- Azure VM Disk的设计与部署
Azure的VM的设计中,Disk相关的设计是非常重要的一个内容,本文将介绍Azure上的VM的Disk相关的一些最佳实践和一些小的技巧. 一.Azure VM中Disk的存储账户设计 1. Stor ...
- 【Azure Developer】VS Code运行Java 版Azure Storage SDK操作Blob (新建Container, 上传Blob文件,下载及清理)
问题描述 是否可以用Java代码来管理Azure blob? 可以.在代码中加入azure-storage-blob依赖.即可使用以下类操作Azure Storage Blob. BlobServic ...
- Windows Azure 系列-- Azure Queue的操作
- Storage Account. 和之前介绍的Azure Table和AzureBlob一样.你须要一个StorageAccount,仅仅须要创建1次AzureStorageAccount就好了, ...
- VMware 虚拟化编程(7) — VixDiskLib 虚拟磁盘库详解之三
目录 目录 前文列表 VixDiskLib 虚拟磁盘库 VixDiskLib_GetMetadataKeys VixDiskLib_ReadMetadata 获取虚拟磁盘元数据 VixDiskLib_ ...
- Azure ARM (20) 将非托管磁盘虚拟机(Unmanage Disk),迁移成托管磁盘虚拟机(Manage Disk)
<Windows Azure Platform 系列文章目录> PowerShell我已经提交到GitHub: https://github.com/leizhang1984/AzureC ...
- Azure REST API (3) 使用REST API,操作Azure ARM VM
<Windows Azure Platform 系列文章目录> 笔者之前遇到一个客户,需求是当发生某一个特定条件的时候,对多台Azure ARM VM执行开机或者关机操作,这个时候就需要使 ...
- 如何使用 Packer 在 Azure 中创建 Windows 虚拟机映像
Azure 中的每个虚拟机 (VM) 都是基于定义 Windows 分发和操作系统版本的映像创建的. 映像可以包括预安装的应用程序和配置. Azure 应用商店为最常见的操作系统和应用程序环境提供了许 ...
随机推荐
- @MarkFan 口语练习录音 20140518 [超凡蜘蛛侠2-格温的演讲[中文]&驯龙骑士选节口语录音]
一个人看不到未来,就把握不了现在 生命中最值得珍惜的,其实并不是永恒的 正因为它会结束,使其变得弥足珍贵,而且将一去不复返 让我们谨记时间就是运气,所以不要把它浪费在别的生活上 让你的生活过得更有价值 ...
- Swift中的? ! as as? as!
?: 代表这是个可选类型(optional)的.如下,如果num有就为Int类型的,如果没有值那么就是nil. let num:Int? 当我对number进行显示赋值时那么number就是Int类型 ...
- Golang 连接Kafka
Kafka介绍 Kafka是Apache软件基金会开发的一个开源流处理平台,由Java和Scala编写:Kafka是一种高吞吐.分布式.基于订阅发布的消息系统. Kafka名称解释 Producer: ...
- python之命令行解析工具argparse
以前写python的时候都会自己在文件开头写一个usgae函数,用来加上各种注释,给用这个脚本的人提供帮助文档. 今天才知道原来python已经有一个自带的命令行解析工具argparse,用了一下,效 ...
- Ubuntu无法使用root用户登陆的解决办法
对于一个新安装的Ubuntu操作系统,经常会遇到无法使用root用户ssh连接操作系统,比如说root用户的密码被拒绝等原因. 面对这种问题,介绍一下Ubuntu无法使用root登陆解决 1. 修改 ...
- 内网批量测试登录机器工具,并且dir 目标机器c盘
// Ipc.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <stdio.h> #include <w ...
- python中的import一个注意事项
import math def foo(): import math x = math.pi # 如果math在下面import会出错,因为import是个写的过程(添加到sys.modules中), ...
- Codeforces Round #371 (Div. 2) A ,B , C 水,水,trie树
A. Meeting of Old Friends time limit per test 1 second memory limit per test 256 megabytes input sta ...
- review09
String类在java.lang包中,由于java.lang包中的类被默认引入,所以可以直接使用String类.String对象的创建可以直接使用带字符串参数的构造方法 String s = new ...
- C语言基础一
C语言学习 C语言的特点 语言简单.紧凑.使用方便.灵活 运算符丰富 数据类型丰富 具有结构化的控制语句 语法限制不太严格,程序设计自由度大 C语言允许直接访问物理地址,可以对硬件进行直接操作 生成代 ...