此脚本使用自定义映像在 China North 位置中名为 myResourceGroupFromImage 的新资源组中创建名为 myVMfromImage 的 VM。 PowerShell复制 $cred=Get-Credential-Message"Enter a username and password for the virtual machine."New-AzureRmResourceGroup-NamemyResourceGroupFromImage-LocationChinaEast$subnetConfig=Ne...
else{$nicname=$vmname}$nic= New-AzureRmNetworkInterface -Name$nicname-ResourceGroupName$rgname-Location$rg.Location -SubnetId$vnet.Subnets[0].Id -PublicIpAddressId$pip.Id#create the VM$vmosname=$hash+$vmname+"osDisk"$vm= New-AzureRmVMConfig -VMName$vmname-VMSize$vmsize-AvailabilitySetId$...
Azure PowerShell 复制 打开Cloud Shell Invoke-AzVMRunCommand ` -ResourceGroupName 'myResourceGroup' ` -Name 'myVM' ` -CommandId 'RunShellScript' ` -ScriptString 'sudo apt-get update && sudo apt-get install -y nginx' 此-ScriptString参数需要模块的版本4.27.0Az.Compute或更高版本。 查看运行...
创建Azure Compute Gallery 如果还没有 Azure Compute Gallery,则需要创建一个。 PowerShell $sigGalleryName="myaibsig01"$imageDefName="win10avd"# Create the galleryNew-AzGallery-GalleryName$sigGalleryName-ResourceGroupName$imageResourceGroup-Location$location# Create the gallery definition...
Azure PowerShell 复制 打开Cloud Shell Invoke-AzVMRunCommand -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -CommandId 'RunPowerShellScript' -ScriptString 'Install-WindowsFeature -Name Web-Server -IncludeManagementTools' 此-ScriptString参数需要模块的版本4.27.0Az.Compute或更高版本。 查看运行...
此脚本使用自定义映像在 China North 位置中名为 myResourceGroupFromImage 的新资源组中创建名为 myVMfromImage 的 VM。 PowerShell复制 $cred = Get-Credential -Message "Enter a username and password for the virtual machine." New-AzureRmResourceGroup -Name myResourceGroupFromImage -Location ChinaEast ...
$vm1 | Set-AzureSubnet -SubnetNames "MyLabNetwork" ###Step3 END till here, we “only” passed the values but didn’t really create the VM, the final command New-AzureVM is required to kick on the real deployment in Azure New-AzureVM –ServiceName "<short name of the cloud service>...
配置一,Json 模板文件上传Azure 存储账户容器内,需要指定模板文件的访问URI地址并且操作用户必须具备访问权限,这里配置为公开匿名访问权限。 注:报错请参考报错验证。 New-AzResourceGroupDeployment-ResourceGroupName Jiahe-Demo-RS03-TemplateUri"https:///stg0lcont0l/CreateVM-l.json" ...
Output of the Get-AzVmSize command Resizing the virtual machine You now know which virtual machine sizes are available. You can now change the size of the virtual machine. Now resize the VM using theUpdate-AzVmcmdlet to Standard_B1ls as an example. The Standard_B1ls size is not required....
Create a new VM config: $vmName="<VM Name>" $vmSize="<VM Size>" $vmc = New-AzureRmVmConfig -VMName $vmName -VMSize $vmSize Add a network interface (in this example, we are reusing the existing NIC from the previous VM) $nic = Get-AzureRmNetworkInterface -Name "<NI...