使用PowerShell创建Azure虚拟机

huangapple go评论67阅读模式
英文:

Creating an Azure VM with powershell

问题

我正在尝试使用以下命令创建一个带有Windows 10专业版的Azure虚拟机,但我无法成功。

我收到了以下错误信息:

使用PowerShell创建Azure虚拟机

我正在尝试查找镜像的名称,但没有成功。

我想要一个非常容易理解的命令。

英文:

I am trying to create an Azure VM with Windows 10 pro with the following command but I am unable.

New-AzVm
-ResourceGroupName "lab2023"

-Name 'vmlab'
-Location "canadacentral"

-Image "win10-22h2-pro"
-VirtualNetworkName "lab2023-vnet"

-SubnetName "lab2023-subnet"
-SecurityGroupName 'labvm-nsg'

-PublicIpAddressName 'vm-ip' `
-OpenPorts 3389

I receive this error
使用PowerShell创建Azure虚拟机

I am trying to find the name of the image, but no luck.

I want to make it very easy command to understand

答案1

得分: 0

Image参数是一个结构化数值,由几个信息片段构建而成,详见文档

> 现在,您可以将所选发布商、产品、SKU和版本合并为一个URN(用冒号分隔的值)。在使用New-AzVM cmdlet创建虚拟机时,将此URN传递给-Image参数。您还可以在URN中用latest替换版本号,以获取图像的最新版本。

一些图像URN的示例在这里。尽管我找不到Windows 10的示例,生成的命令看起来像:

New-AzVm
-ResourceGroupName "myResourceGroupVM"
-Name "myVM2"
-Location "EastUS"
-VirtualNetworkName "myVnet"
-SubnetName "mySubnet"
-SecurityGroupName "myNetworkSecurityGroup"
-PublicIpAddressName "myPublicIpAddress2"
-ImageName "MicrosoftWindowsServer:WindowsServer:2016-Datacenter-with-Containers:latest"
-Credential $cred
-AsJob

英文:

The Image parameter is a structured value built up from several pieces of information as per documentation:

> Now you can combine the selected publisher, offer, SKU, and version into a URN (values separated by :). Pass this URN with the -Image parameter when you create a VM with the New-AzVM cmdlet. You can also replace the version number in the URN with latest to get the latest version of the image.

Some examples of image urns are here although I cannot find one for Windows 10, and the resulting command looks like:

New-AzVm
-ResourceGroupName "myResourceGroupVM"
-Name "myVM2"

-Location "EastUS"
-VirtualNetworkName "myVnet"

-SubnetName "mySubnet"
-SecurityGroupName "myNetworkSecurityGroup"

-PublicIpAddressName "myPublicIpAddress2"
-ImageName "MicrosoftWindowsServer:WindowsServer:2016-Datacenter-with-Containers:latest"

-Credential $cred
-AsJob

huangapple
  • 本文由 发表于 2023年3月7日 12:31:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75658067.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定