你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzGalleryImageDefinition

创建库映像定义。

语法

Default (默认值)

New-AzGalleryImageDefinition
    [-ResourceGroupName] <String>
    [-GalleryName] <String>
    [-Name] <String>
    [-AsJob]
    [-Location] <String>
    -Publisher <String>
    -Offer <String>
    -Sku <String>
    -OsState <OperatingSystemStateTypes>
    -OsType <OperatingSystemTypes>
    [-Description <String>]
    [-DisallowedDiskType <String[]>]
    [-EndOfLifeDate <DateTime>]
    [-Eula <String>]
    [-HyperVGeneration <String>]
    [-MinimumMemory <Int32>]
    [-MinimumVCPU <Int32>]
    [-MaximumMemory <Int32>]
    [-MaximumVCPU <Int32>]
    [-PrivacyStatementUri <String>]
    [-PurchasePlanName <String>]
    [-PurchasePlanProduct <String>]
    [-PurchasePlanPublisher <String>]
    [-ReleaseNoteUri <String>]
    [-Tag <Hashtable>]
    [-Feature <GalleryImageFeature[]>]
    [-Architecture <String>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

创建库映像定义。 如果-HyperVGeneration-Feature @{Name: SecurityType}未显式设置,库映像定义将默认为“HyperVGeneration: V2”和“SecurityType: TrustedLaunchSupported”。 将 SecurityType 设置为“None”以选择退出此默认设置(请参阅示例 10)。

示例

示例 1:为专用 Linux 映像创建映像定义

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$description = "My gallery"
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Specialized" -OsType "Linux" -Description $description

创建库映像定义以包含专用 Linux 映像的映像版本。 这会将库映像默认为 HyperVGeneration V2 和受信任的启动 -HyperVGeneration ,并且 -Feature SecurityType 未显式设置。

示例 2:为通用 Linux 映像创建映像定义

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$description = "My gallery"
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -Description $description

创建库映像定义以包含通用 Linux 映像的映像版本。

示例 3:为专用 Windows 映像创建映像定义

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$description = "My gallery"
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Specialized" -OsType "Windows" -Description $description

创建库映像定义以包含专用 Windows 映像的映像版本。

示例 4:为通用 Windows 映像创建映像定义并设置功能。

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$description = "My gallery"
$IsHibernateSupported = @{Name='IsHibernateSupported';Value='True'}
$IsAcceleratedNetworkSupported = @{Name='IsAcceleratedNetworkSupported';Value='False'}
$ConfidentialVMSupported = @{Name='SecurityType';Value='ConfidentialVMSupported'}
$features = @($IsHibernateSupported,$IsAcceleratedNetworkSupported, $ConfidentialVMSupported)
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Windows" -Description $description -Feature $features -HyperVGeneration "V2"

创建库映像定义以包含通用化 Windows 映像的映像版本。

示例 5:使用计划信息创建映像定义

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$purchasePlanName = "myPlanName"
$purchasePlanProduct = "myPlanProduct"
$purchasePlanPublisher = "myPlanPublisher"
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -PurchasePlanName $purchasePlanName -PurchasePlanProduct $purchasePlanProduct -PurchasePlanPublisher $purchasePlanPublisher

为 Linux 通用映像创建库映像定义,并定义计划名称、产品和发布者。 只有与计划信息匹配的映像版本才能添加到此定义中。

示例 6:创建映像定义并指示生命周期结束日期

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$endOfLifeDate = "2024-08-02T00:00:00+00:00"
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -EndOfLifeDate $endOfLifeDate

本示例将图像定义的生命周期结束日期设置为 2024 年 8 月 2 日午夜 UTC。 可以为映像定义和映像版本指定生命周期结束日期。 映像定义仍可在生命周期结束日期后使用。

示例 7:创建映像定义,并建议最小和最大 CPU 和内存(GB)

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$minMemory = 32
$maxMemory = 128
$minVCPU = 2
$maxVCPU = 8
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -MinimumMemory $minMemory -MaximumMemory $maxMemory -MinimumVCPU $minVCPU -MaximumVCPU $maxVCPU

创建库映像定义,并建议此映像定义中映像版本支持的 CPU 和内存的最小和最大范围。 映像版本仍可用于在建议范围之外创建内存和 vCPU 设置的虚拟机。

示例 8:创建映像定义并指示映像不建议使用哪些 OS 磁盘类型

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$disallowedDiskTypes = @("Standard_LRS")
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -DisallowedDiskType $disallowedDiskTypes

创建库映像定义并指示哪些 OS 磁盘类型可能与此映像定义中的映像版本不兼容。 映像版本仍可用于创建具有 OS 磁盘的虚拟机,该磁盘是不允许的磁盘类型之一。

示例 9:创建映像定义并提供 EULA、隐私声明 URI 和发行说明 URI

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"
$eula = "https://myeula"
$privacyStatementUri = "https://mystatement"
$releaseNoteUri = "https://myreleasenotes"
New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -Eula $eula -PrivacyStatementUri $privacyStatementUri -ReleaseNoteUri $releaseNoteUri

为 Linux 通用映像创建库映像定义,并指定 EULA 协议、隐私声明和绑定到映像定义中所有映像版本的字符串或路径。

示例 10:使用 Standard SecurityType 功能创建库映像定义

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$location = "eastus"
$publisherName = "GreatPublisher"
$offerName = "GreatOffer"
$skuName = "GreatSku"

$Feature1 = @{Name='SecurityType';Value='None'}
$Features = @($Feature1)

New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Linux" -Feature $Features

通过将“None”作为 SecurityType 功能的值来创建具有标准安全类型功能的库映像定义。

参数

-Architecture

OS 磁盘支持的 CPU 体系结构。 可能的值为“X64”和“Arm64”。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-AsJob

在后台运行 cmdlet

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

在运行 cmdlet 之前,提示你进行确认。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

参数属性

类型:IAzureContextContainer
默认值:None
支持通配符:False
不显示:False
别名:AzContext, AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Description

库映像定义资源的说明。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-DisallowedDiskType

不允许的磁盘类型。

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-EndOfLifeDate

库映像定义的生命周期结束日期

参数属性

类型:DateTime
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Eula

库映像定义的 Eula 协议。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Feature

库映像功能的列表。 对于 SecurityType,可接受的输入为:None、TrustedlaunchSupported、Trustedlaunch、ConfidentialVM、ConfidentialVMSupported、TrustedLaunchAndConfidentialVmSupported

参数属性

类型:

GalleryImageFeature[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-GalleryName

库的名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-HyperVGeneration

虚拟机的虚拟机监控程序生成。 仅适用于 OS 磁盘。 允许的值为 V1 和 V2。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Location

资源位置

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:3
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MaximumMemory

建议的最大内存

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MaximumVCPU

建议的最大 CPU 核心数

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MinimumMemory

建议的内存的最小值

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MinimumVCPU

建议的 CPU 内核的最小值

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Name

库映像定义的名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:GalleryImageDefinitionName

参数集

(All)
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Offer

库映像定义产品/服务的名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-OsState

OS 的状态

参数属性

类型:OperatingSystemStateTypes
默认值:None
接受的值:Generalized, Specialized
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-OsType

OS 的类型

参数属性

类型:OperatingSystemTypes
默认值:None
接受的值:Windows, Linux
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-PrivacyStatementUri

隐私声明 URI。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Publisher

库映像定义发布者的名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-PurchasePlanName

购买计划的 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-PurchasePlanProduct

购买计划的产品 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-PurchasePlanPublisher

购买计划的发布者 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ReleaseNoteUri

发行说明 URI。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ResourceGroupName

资源组的名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Sku

库映像定义 SKU 的名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Tag

资源标记

参数属性

类型:Hashtable
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-WhatIf

显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输入

String

OperatingSystemStateTypes

OperatingSystemTypes

DateTime

Hashtable

Int32

String

输出

PSGalleryImage