创建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...
后面的步骤是创建映像,然后根据该映像创建 VM。 若要创建映像,请执行以下过程: 设置要在生成过程中使用的变量: Azure # Destination image resource group name$imageResourceGroup='ContosoWinImgBuilderRG'# Azure region$location='WestUS2'# Name of the image to...
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或更高版本。 查看运行...
此脚本使用自定义映像在 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...
Azure PowerShell $rgName="myResourceGroup"$vmName="myVM"$dataDiskName="myDisk"$disk=Get-AzDisk-ResourceGroupName$rgName-DiskName$dataDiskName$vm=Get-AzVM-Name$vmName-ResourceGroupName$rgName$vm=Add-AzVMDataDisk-CreateOptionAttach-Lun0-VM$vm-ManagedDiskId$disk.IdUpdate-AzVM-VM$vm-Resourc...
PublicIpAddressId$pip.Id#create the VM$vmosname=$hash+$vmname+"osDisk"$vm= New-AzureRmVMConfig -VMName$vmname-VMSize$vmsize-AvailabilitySetId$haset.Id$vm= Add-AzureRmVMNetworkInterface -VM$vm-NetworkInterface$nic$vm= Set-AzureRmVMOSDisk -VM$vm-Name$vmosname-VhdUri$osDiskURL-CreateOption...
此脚本使用自定义映像在 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 ...
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 $vmSizeAdd a network interface (in this example, we are reusing the existing NIC from the previous VM) $nic = Get-AzureRmNetworkInterface -Name "<NIC ...
create a variable to store information about the image$image=Get-AzureRmImage`-ImageNamemyImage `-ResourceGroupNamemyResourceGroup# Here is where we specify that we want to create the VM from and image and provide the image ID$vmConfig=Set-AzureRmVMSourceImage-VM$vmConfig-Id$image.Id$vm...