在Microsoft Azure中使用CLI中的映像(.VHD)创建Windows VM
我在创建映像并从该映像创建虚拟机时遇到了Azure新门户的问题。 虽然使用一些帮助 “https://azure.microsoft.com/en-in/documentation/articles/virtual-machines-windows-capture-image/#comments”我可以使用CLI创建一个图像,但是从该图像创建一个虚拟机时,只有很少的命令会引发错误。需要以在Microsoft Azure中使用CLI中的映像(.VHD)创建Windows VM
帮助作为链接文件中给出:
$vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location -AddressPrefix $vnetAddressPrefix -Subnet $subnetconfig
我的版本:
$vnet = New-AzureRmVirtualNetwork -Name myvirtualnetwork -ResourceGroupName my_Resource_Group -Location southus -AddressPrefix 10.0.0.0/** -Subnet 10.0.0.0/**
** - >一些数量
下面是我得到的错误在电源外壳上:
New-AzureRmVirtualNetwork : Cannot bind parameter 'Subnet'. Cannot convert the "10.0.0.0/**" value of type
"System.String" to type "Microsoft.Azure.Commands.Network.Models.PSSubnet".
At line:1 char:153
+ ... 0.0/16 -Subnet 10.0.0.0/**
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-AzureRmVirtualNetwork], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Network.NewAzureVirtualNetworkCommand
参数-Subnet预计类型为“Microsoft.Azure.Commands.Network.Models.PSSubnet”的变量。也就是说,不是直接将子网作为字符串传递,而必须传递一个对象。
尝试(请确保相应地更改参数):
$VnetName = "MyVNET"
$AddressPrefix = "10.0.0.0/24"
$SubnetName = "Subnet-1"
$SubnetPrefix = "10.0.0.0/27"
$ResouceGroup = "MyRG"
$Location = "eastus"
$subnetconfig = New-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetPrefix
$vnet = New-AzureRmVirtualNetwork -Name $VnetName -ResourceGroupName $ResouceGroup -Location $Location -AddressPrefix $AddressPrefix -Subnet $subnetconfig
BTW:
“southus” 是不是有效的位置。使用Get-AzureRmLocation列出所有可用的
“10.0.0.0/**”不是有效的前缀。您必须定义要使用的正确网段。
烨是工作在执行 – user4021949
现在得到这个错误“$ NIC =新建 - AzureRmNetworkInterface -Name $ nicname -ResourceGroupName $ rgName -Location $ location -SubnetId $ vnet.Subnets [0] .Id -PublicIpAddressId $ pip.Id“ – user4021949
错误说:引用公共IP地址 – user4021949
错误消息告诉你的问题是什么,它想要一个pssubnet对象,而不是字符串 - 看看'新AzureRmVirtualNetworkSubnetConfig' –