Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions src/azure-cli/azure/cli/command_modules/vm/_image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def create_image_template( # pylint: disable=too-many-locals, too-many-branches
ImageTemplateShellCustomizer, ImageTemplatePowerShellCustomizer,
ImageTemplateManagedImageDistributor,
ImageTemplateSharedImageDistributor, ImageTemplateIdentity,
ImageTemplateIdentityUserAssignedIdentitiesValue,
ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties, # pylint: disable=line-too-long
ImageTemplateVmProfile, VirtualNetworkConfig)

if image_template is not None:
Expand Down Expand Up @@ -422,7 +422,7 @@ def create_image_template( # pylint: disable=too-many-locals, too-many-branches
content['tags'] = obj['tags']
if 'identity' in obj:
content['identity'] = obj['identity']
return client.virtual_machine_image_templates.create_or_update(
return client.virtual_machine_image_templates.begin_create_or_update(
parameters=content, resource_group_name=resource_group_name, image_template_name=image_template_name)

template_source, template_scripts, template_destinations = None, [], []
Expand Down Expand Up @@ -473,14 +473,15 @@ def create_image_template( # pylint: disable=too-many-locals, too-many-branches
if not is_valid_resource_id(ide):
ide = resource_id(subscription=subscription_id, resource_group=resource_group_name,
namespace='Microsoft.ManagedIdentity', type='userAssignedIdentities', name=ide)
user_assigned_identities[ide] = ImageTemplateIdentityUserAssignedIdentitiesValue()
user_assigned_identities[ide] = ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties() # pylint: disable=line-too-long
identity_body = ImageTemplateIdentity(type='UserAssigned', user_assigned_identities=user_assigned_identities)

# VM profile
vnet_config = None
if vnet or subnet:
if not is_valid_resource_id(subnet):
subnet = resource_id(subscription=client.config.subscription_id, resource_group=resource_group_name,
subscription_id = get_subscription_id(cmd.cli_ctx)
subnet = resource_id(subscription=subscription_id, resource_group=resource_group_name,
namespace='Microsoft.Network', type='virtualNetworks', name=vnet,
child_type_1='subnets', child_name_1=subnet)
vnet_config = VirtualNetworkConfig(subnet_id=subnet)
Expand All @@ -490,7 +491,7 @@ def create_image_template( # pylint: disable=too-many-locals, too-many-branches
location=location, build_timeout_in_minutes=build_timeout, tags=(tags or {}),
identity=identity_body, vm_profile=vm_profile)

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=image_template,
resource_group_name=resource_group_name, image_template_name=image_template_name)


Expand Down Expand Up @@ -547,7 +548,7 @@ def add_template_output(cmd, client, resource_group_name, image_template_name, g

existing_image_template.distribute.append(distributor)

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=existing_image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=existing_image_template, # pylint: disable=line-too-long
resource_group_name=resource_group_name, image_template_name=image_template_name)


Expand All @@ -571,7 +572,7 @@ def remove_template_output(cmd, client, resource_group_name, image_template_name

existing_image_template.distribute = new_distribute

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=existing_image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=existing_image_template, # pylint: disable=line-too-long
resource_group_name=resource_group_name, image_template_name=image_template_name)


Expand All @@ -586,7 +587,7 @@ def clear_template_output(cmd, client, resource_group_name, image_template_name)

existing_image_template.distribute = []

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=existing_image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=existing_image_template, # pylint: disable=line-too-long
resource_group_name=resource_group_name, image_template_name=image_template_name)


Expand Down Expand Up @@ -635,7 +636,7 @@ def add_template_customizer(cmd, client, resource_group_name, image_template_nam

existing_image_template.customize.append(new_customizer)

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=existing_image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=existing_image_template, # pylint: disable=line-too-long
resource_group_name=resource_group_name, image_template_name=image_template_name)


Expand All @@ -659,7 +660,7 @@ def remove_template_customizer(cmd, client, resource_group_name, image_template_

existing_image_template.customize = new_customize

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=existing_image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=existing_image_template, # pylint: disable=line-too-long
resource_group_name=resource_group_name, image_template_name=image_template_name)


Expand All @@ -675,7 +676,7 @@ def clear_template_customizer(cmd, client, resource_group_name, image_template_n

existing_image_template.customize = []

return cached_put(cmd, client.virtual_machine_image_templates.create_or_update, parameters=existing_image_template,
return cached_put(cmd, client.virtual_machine_image_templates.begin_create_or_update, parameters=existing_image_template, # pylint: disable=line-too-long
resource_group_name=resource_group_name, image_template_name=image_template_name)

# endregion
8 changes: 4 additions & 4 deletions src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ def load_command_table(self, _):
g.custom_command('create', 'create_image_template', supports_no_wait=True, supports_local_cache=True, validator=process_image_template_create_namespace)
g.custom_command('list', 'list_image_templates')
g.show_command('show', 'get')
g.command('delete', 'delete')
g.generic_update_command('update', 'create_or_update', supports_local_cache=True) # todo Update fails for now as service does not support updates
g.command('delete', 'begin_delete')
g.generic_update_command('update', setter_name='begin_create_or_update', supports_local_cache=True) # todo Update fails for now as service does not support updates
g.wait_command('wait')
g.command('run', 'run', supports_no_wait=True)
g.command('run', 'begin_run', supports_no_wait=True)
g.custom_command('show-runs', 'show_build_output')
g.command('cancel', 'cancel')
g.command('cancel', 'begin_cancel')

with self.command_group('image builder customizer', image_builder_image_templates_sdk, custom_command_type=image_builder_custom) as g:
g.custom_command('add', 'add_template_customizer', supports_local_cache=True, validator=process_img_tmpl_customizer_add_namespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -620,7 +620,7 @@ interactions:
- python/3.8.9 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-imagebuilder/0.4.0 Azure-SDK-For-Python AZURECLI/2.27.2
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -686,7 +686,7 @@ interactions:
accept-language:
- en-US
method: POST
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/run?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/run?api-version=2021-10-01
response:
body:
string: ''
Expand Down Expand Up @@ -1696,7 +1696,7 @@ interactions:
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/runOutputs/img_1?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/runOutputs/img_1?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"artifactId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.Compute/images/img_1\",\n
Expand Down Expand Up @@ -2612,7 +2612,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"imageId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.Compute/images/img_1\",\n
Expand Down Expand Up @@ -2768,7 +2768,7 @@ interactions:
- python/3.8.9 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-imagebuilder/0.4.0 Azure-SDK-For-Python AZURECLI/2.27.2
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"imageId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_managed000001/providers/Microsoft.Compute/images/img_1\",\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -1169,7 +1169,7 @@ interactions:
- python/3.8.9 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-imagebuilder/0.4.0 Azure-SDK-For-Python AZURECLI/2.28.1
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -1235,7 +1235,7 @@ interactions:
accept-language:
- en-US
method: POST
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/run?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/run?api-version=2021-10-01
response:
body:
string: ''
Expand Down Expand Up @@ -3109,7 +3109,7 @@ interactions:
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/runOutputs/image1?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01/runOutputs/image1?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"artifactId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.Compute/galleries/ib_sig000003/images/image1/versions/0.24916.4472\",\n
Expand Down Expand Up @@ -4087,7 +4087,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"imageVersionId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.Compute/galleries/ib_sig000003/images/image1/versions/0.24916.4472\",\n
Expand Down Expand Up @@ -4243,7 +4243,7 @@ interactions:
- python/3.8.9 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-imagebuilder/0.4.0 Azure-SDK-For-Python AZURECLI/2.28.1
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"imageVersionId\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_sig000001/providers/Microsoft.Compute/galleries/ib_sig000003/images/image1/versions/0.24916.4472\",\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -1398,7 +1398,7 @@ interactions:
- python/3.8.3 (Windows-10-10.0.18362-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-imagebuilder/0.4.0 Azure-SDK-For-Python AZURECLI/2.29.0
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template01?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -1658,7 +1658,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down Expand Up @@ -1818,7 +1818,7 @@ interactions:
- python/3.8.3 (Windows-10-10.0.18362-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-imagebuilder/0.4.0 Azure-SDK-For-Python AZURECLI/2.29.0
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2020-02-14
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/img_tmpl_basic000001/providers/Microsoft.VirtualMachineImages/imageTemplates/template02?api-version=2021-10-01
response:
body:
string: "{\n \"properties\": {\n \"source\": {\n \"offer\": \"UbuntuServer\",\n
Expand Down
Loading