Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def default_api_version(self):
'snapshots': '2020-12-01',
'galleries': '2019-12-01',
'gallery_images': '2020-09-30',
'gallery_image_versions': '2019-12-01',
'gallery_image_versions': '2020-09-30',
'virtual_machine_scale_sets': '2020-12-01'
}),
ResourceType.MGMT_RESOURCE_FEATURES: '2015-12-01',
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@
- name: Add a new image version using disks with target regions and customer managed keys for encryption. You specify which disks in the image version to encrypt. Disks encrypted in one region must be encrypted in another region with a different disk encryption set.
text: >
az sig image-version create -g MyResourceGroup --gallery-image-version 1.0.0 --target-regions westus=2=standard eastus --target-region-encryption WestUSDiskEncryptionSet1,0,WestUSDiskEncryptionSet2 EastUSDiskEncryptionSet1,0,EastUSDiskEncryptionSet2 --gallery-name MyGallery --gallery-image-definition MyImage --os-snapshot /subscriptions/00000000-0000-0000-0000-00000000xxxx/resourceGroups/imageGroups/providers/Microsoft.Compute/disks/MyOSDisk --data-snapshots /subscriptions/00000000-0000-0000-0000-00000000xxxx/resourceGroups/imageGroups/providers/Microsoft.Compute/disks/MyDataDisk --data-snapshot-luns 0
- name: Add a new image version from a VHD of an OS disk.
text: >
az sig image-version create -g MyResourceGroup --gallery-name MyGallery --gallery-image-definition MyImage --gallery-image-version 1.0.0 --os-vhd-uri <vhd-uri> --os-vhd-storage-account account
"""

helps['sig image-version update'] = """
Expand Down
4 changes: 3 additions & 1 deletion src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def load_arguments(self, _):
c.argument('gallery_image_version_name', options_list=['--gallery-image-version', '-e', deprecated_option],
help='Gallery image version in semantic version pattern. The allowed characters are digit and period. Digits must be within the range of a 32-bit integer, e.g. `<MajorVersion>.<MinorVersion>.<Patch>`')

with self.argument_context('sig image-version create') as c:
with self.argument_context('sig image-version create', resource_type=ResourceType.MGMT_COMPUTE, operation_group='gallery_image_versions') as c:
c.argument('gallery_image_version', options_list=['--gallery-image-version', '-e'],
help='Gallery image version in semantic version pattern. The allowed characters are digit and period. Digits must be within the range of a 32-bit integer, e.g. `<MajorVersion>.<MinorVersion>.<Patch>`')
c.argument('description', help='the description of the gallery image version')
Expand All @@ -946,6 +946,8 @@ def load_arguments(self, _):
arg_type=get_enum_type(["Standard_LRS", "Standard_ZRS", "Premium_LRS"]), min_api='2019-03-01')
c.argument('target_region_encryption', nargs='+',
help='Space-separated list of customer managed keys for encrypting the OS and data disks in the gallery artifact for each region. Format for each region: `<os_des>,<lun1>,<lun1_des>,<lun2>,<lun2_des>`. Use "null" as a placeholder.')
c.argument('os_vhd_uri', help='Source VHD URI of OS disk')
c.argument('os_vhd_storage_account', help='Name or ID of storage account of source VHD URI of OS disk')

with self.argument_context('sig image-version show') as c:
c.argument('expand', help="The expand expression to apply on the operation, e.g. 'ReplicationStatus'")
Expand Down
21 changes: 17 additions & 4 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from knack.util import CLIError

from azure.cli.command_modules.vm._validators import _get_resource_group_from_vault_name
from azure.cli.core.azclierror import ValidationError
from azure.cli.core.commands.validators import validate_file_or_dict

from azure.cli.core.commands import LongRunningOperation, DeploymentOutputLongRunningOperation
Expand Down Expand Up @@ -418,7 +419,7 @@ def list_managed_disks(cmd, resource_group_name=None):
def update_managed_disk(cmd, resource_group_name, instance, size_gb=None, sku=None, disk_iops_read_write=None,
disk_mbps_read_write=None, encryption_type=None, disk_encryption_set=None,
network_access_policy=None, disk_access=None, max_shares=None, disk_iops_read_only=None,
disk_mbps_read_only=None, enable_bursting=False):
disk_mbps_read_only=None, enable_bursting=None):
from msrestazure.tools import resource_id, is_valid_resource_id
from azure.cli.core.commands.client_factory import get_subscription_id

Expand Down Expand Up @@ -3390,7 +3391,7 @@ def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_n
location=None, target_regions=None, storage_account_type=None,
end_of_life_date=None, exclude_from_latest=None, replica_count=None, tags=None,
os_snapshot=None, data_snapshots=None, managed_image=None, data_snapshot_luns=None,
target_region_encryption=None):
target_region_encryption=None, os_vhd_uri=None, os_vhd_storage_account=None):
# print(target_regions)
from msrestazure.tools import resource_id, is_valid_resource_id
from azure.cli.core.commands.client_factory import get_subscription_id
Expand Down Expand Up @@ -3421,8 +3422,8 @@ def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_n
source=source, replica_count=replica_count,
storage_account_type=storage_account_type)
if cmd.supported_api_version(min_api='2019-07-01', operation_group='gallery_image_versions'):
if managed_image is None and os_snapshot is None:
raise CLIError('usage error: Please provide --managed-image or --os-snapshot')
if managed_image is None and os_snapshot is None and os_vhd_uri is None:
raise CLIError('usage error: Please provide --managed-image or --os-snapshot or --vhd')
GalleryImageVersionStorageProfile = cmd.get_models('GalleryImageVersionStorageProfile')
GalleryArtifactVersionSource = cmd.get_models('GalleryArtifactVersionSource')
GalleryOSDiskImage = cmd.get_models('GalleryOSDiskImage')
Expand All @@ -3443,6 +3444,18 @@ def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_n
for i, s in enumerate(data_snapshots):
data_disk_images.append(GalleryDataDiskImage(source=GalleryArtifactVersionSource(id=s),
lun=data_snapshot_luns[i]))
# from vhd, only support os image now
if cmd.supported_api_version(min_api='2020-09-30', operation_group='gallery_image_versions'):
if os_vhd_uri and os_vhd_storage_account is None or os_vhd_uri is None and os_vhd_storage_account:
raise ValidationError('--vhd and --vhd-storage-account should be used together.')
if os_vhd_uri and os_vhd_storage_account:
if not is_valid_resource_id(os_vhd_storage_account):
os_vhd_storage_account = resource_id(
subscription=get_subscription_id(cmd.cli_ctx), resource_group=resource_group_name,
namespace='Microsoft.Storage', type='storageAccounts', name=os_vhd_storage_account)
os_disk_image = GalleryOSDiskImage(source=GalleryArtifactVersionSource(
id=os_vhd_storage_account, uri=os_vhd_uri))

storage_profile = GalleryImageVersionStorageProfile(source=source, os_disk_image=os_disk_image,
data_disk_images=data_disk_images)
image_version = ImageVersion(publishing_profile=profile, location=location, tags=(tags or {}),
Expand Down
Loading