Azure: List OS Images

丶灬走出姿态 提交于 2019-12-22 09:15:20

问题


Im new to windows azure, Ive looked to this documentation, to me it works, Listing Images on gallery. https://management.core.windows.net/subscription-id/services/images

But this isnt what Im looking for, Is there a way to list the My Images on my account and not the images on gallery.


回答1:


If you run the PowerShell cmdlet Get-AzureVMImage, you'll see all images. As stated by @Gaurav, The ones that correlate to My Images have a PublisherName of User. So, again, using PowerShell, here's how to see just your images by piping to Where-Object:

Get-AzureVMImage | Where-Object { $_.PublisherName -eq 'User' }

If you wanted to see the image names in your console, you could pipe it to ForEach-Object:

Get-AzureVMImage | Where-Object { $_.PublisherName -eq 'User' } |
ForEach-Object { Write-Host $_.ImageName }

Note: If your image's PublisherName is empty, use Category -eq 'User' instead.

Here's sample output, from my subscription:

EDIT If you're using the Mac/Linux CLI, you'd run a slightly different command:

azure vm image list

Or, to return json:

azure vm image list --json

Once you have json, you could, for example, pipe to a command line tool such as jsontool to get your own image names (the image name is returned in the Name key):

azure vm image list --json | json -a -c 'this.Category == "User"' Name



回答2:


You would still use the same operation. The operation returns both system defined (i.e. gallery) and user defined images. To see only the user defined images, you would need to filter on PublisherName which would be User for user defined images. This is what the documentation states:

PublisherName: The name of the publisher of the image. All user images have a publisher name of User.




回答3:


Try the below command. It works with Category as User rather than publisher name.

Solution:

Get-AzureVMImage | Where-Object { $_.Category -match 'User'} | 
ForEach-Object { Write-Host $_.ImageName }


来源:https://stackoverflow.com/questions/17965779/azure-list-os-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!