使用azure cli从自定义vhd创建图像

时间:2016-07-10 07:18:17

标签: java azure azure-cli

我看到了从vhd文件创建图像并使用该图像文件创建vm的示例。我正在使用arm模式,并希望将我上传的vhd列为图像。基本上我想使用azure cli / java sdk在以下文章https://azure.microsoft.com/en-in/documentation/articles/virtual-machines-windows-classic-createupload-vhd/中执行第5步。我没有看到任何这样做的例子。 有一个cli命令< azure vm image create',但在azure-cli版本0.10.1中是否已弃用?我为mac安装了一个预编译的azure-cli版本。

1 个答案:

答案 0 :(得分:0)

据我所知,没有证据表明在azure-cli版本0.10.1中不支持命令azure vm image create。您现在可以通过命令npm update -g azure-cli将azure-cli版本升级到0.10.2。

要执行article的第5步,您可以尝试参考文章的第Commands to manage your Azure virtual machine images部分" Azure服务管理(asm)模式下的Azure CLI命令"要使用azure vm image create模式下的ASM命令,请参阅以下步骤。

# Sets the cli wording mode with asm
$ azure config mode asm
# See the help manual for the command `vm image create`
$ azure vm image creaet -h
help:    Upload and register a VM image
help:    
help:    Usage: vm image create [options] <name> [source-path]
help:    
help:    Options:
help:      -h, --help                   output usage information
help:      -v, --verbose                use verbose output
help:      -vv                          more verbose with debug output
help:      --json                       use json output
help:      -u, --blob-url <url>         the target image blob url
help:      -l, --location <name>        the location
help:      -a, --affinity-group <name>  the affinity group
help:      -o, --os <type>              the operating system [linux|windows]
help:      -p, --parallel <number>      the maximum number of parallel uploads [96]
help:      -m, --md5-skip               skip MD5 hash computation
help:      -f, --force-overwrite        Force overwrite of prior uploads
help:      -e, --label <about>          the image label
help:      -d, --description <about>    the image description
help:      -b, --base-vhd <blob>        the base vhd blob url
help:      -k, --source-key <key>       the source storage key if source-path
help:                               is a Microsoft Azure private blob url
help:      -s, --subscription <id>      the subscription id
help:    
help:    Current Mode: asm (Azure Service Management)
# Does the step 5 like Azure-AddVMImage
$ azure vm image create <ImageName> -b <vhd-blob-url> -o <ostype: linux|windows>

与此同时,我认为从自定义映像创建虚拟机的简单方法是从模板中使用带有ARM的Azure CLI,您可以在GitHub上使用article引用the template sample