Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [ARM] Bump azure-mgmt-resource from v2019-07-01 to v2020-06-01 #14266

Closed
wants to merge 5 commits into from
Closed
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
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):
ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_POLICY: '2019-09-01',
ResourceType.MGMT_RESOURCE_RESOURCES: '2019-07-01',
ResourceType.MGMT_RESOURCE_RESOURCES: '2020-06-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2019-06-01',
ResourceType.MGMT_RESOURCE_DEPLOYMENTSCRIPTS: '2019-10-01-preview',
ResourceType.MGMT_NETWORK_DNS: '2018-05-01',
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'requests~=2.22',
'six~=1.12',
'pkginfo>=1.5.0.1',
'azure-mgmt-resource==10.0.0',
'azure-mgmt-resource==10.1.0',
'azure-mgmt-core==1.0.0'
]

Expand Down
9 changes: 6 additions & 3 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,16 +1054,19 @@ def _invoke_deployment(cli_ctx, resource_group_name, deployment_name, template,
subscription_id=None):

from azure.cli.core.profiles import ResourceType, get_sdk
DeploymentProperties = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'DeploymentProperties', mod='models')
Deployment, DeploymentProperties = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'Deployment', 'DeploymentProperties', mod='models')
properties = DeploymentProperties(template=template, parameters=parameters, mode='incremental')
deployment = Deployment(properties=properties)
smc = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).deployments
if validate:
logger.info('==== BEGIN TEMPLATE ====')
logger.info(json.dumps(template, indent=2))
logger.info('==== END TEMPLATE ====')
return smc.validate(resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, properties)
validation_poller = smc.validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cli_ctx)(validation_poller)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, deployment)


def k8s_get_credentials(cmd, client, name, resource_group_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class BotTemplateDeployer:
def deploy_arm_template(cli_ctx, resource_group_name, # pylint: disable=too-many-arguments
template_file=None, deployment_name=None,
parameters=None, mode=None):
DeploymentProperties, _ = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'DeploymentProperties', 'TemplateLink', mod='models')
Deployment, DeploymentProperties = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'Deployment', 'DeploymentProperties', mod='models')

template = {}
# TODO: get_file_json() can return None if specified, otherwise it can throw an error.
Expand All @@ -44,12 +44,13 @@ def deploy_arm_template(cli_ctx, resource_group_name, # pylint: disable=too-man

properties = DeploymentProperties(template=template, template_link=None,
parameters=parameters, mode=mode)
deployment = Deployment(properties=properties)

resource_management_client = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
return LongRunningOperation(cli_ctx, 'Deploying ARM Tempalte')(
resource_management_client.deployments.create_or_update(resource_group_name,
deployment_name,
properties, raw=False))
deployment, raw=False))

@staticmethod
def create_app(cmd, logger, client, resource_group_name, resource_name, description, kind, appid, password, # pylint:disable=too-many-statements
Expand Down
33 changes: 24 additions & 9 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def create_application_gateway(cmd, application_gateway_name, resource_group_nam
from azure.cli.command_modules.network._template_builder import (
build_application_gateway_resource, build_public_ip_resource, build_vnet_resource)

DeploymentProperties = cmd.get_models('DeploymentProperties', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
Deployment, DeploymentProperties = cmd.get_models('Deployment', 'DeploymentProperties',
resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
IPAllocationMethod = cmd.get_models('IPAllocationMethod')

tags = tags or {}
Expand Down Expand Up @@ -222,11 +223,15 @@ def create_application_gateway(cmd, application_gateway_name, resource_group_nam
deployment_name = 'ag_deploy_' + random_string(32)
client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments
properties = DeploymentProperties(template=template, parameters=parameters, mode='incremental')
deployment = Deployment(properties=properties)
if validate:
from azure.cli.core.commands import LongRunningOperation

_log_pprint_template(template)
return client.validate(resource_group_name, deployment_name, properties)
validation_poller = client.validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, deployment)


def update_application_gateway(cmd, instance, sku=None, capacity=None, tags=None, enable_http2=None, min_capacity=None,
Expand Down Expand Up @@ -2707,7 +2712,8 @@ def create_load_balancer(cmd, load_balancer_name, resource_group_name, location=
from azure.cli.command_modules.network._template_builder import (
build_load_balancer_resource, build_public_ip_resource, build_vnet_resource)

DeploymentProperties = cmd.get_models('DeploymentProperties', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
Deployment, DeploymentProperties = cmd.get_models('Deployment', 'DeploymentProperties',
resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
IPAllocationMethod = cmd.get_models('IPAllocationMethod')

tags = tags or {}
Expand Down Expand Up @@ -2763,11 +2769,15 @@ def create_load_balancer(cmd, load_balancer_name, resource_group_name, location=
deployment_name = 'lb_deploy_' + random_string(32)
client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments
properties = DeploymentProperties(template=template, parameters={}, mode='incremental')
deployment = Deployment(properties=properties)
if validate:
from azure.cli.core.commands import LongRunningOperation

_log_pprint_template(template)
return client.validate(resource_group_name, deployment_name, properties)
validation_poller = client.validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, deployment)


def create_lb_inbound_nat_rule(
Expand Down Expand Up @@ -5654,7 +5664,8 @@ def create_vpn_connection(cmd, resource_group_name, connection_name, vnet_gatewa
from azure.cli.command_modules.network._template_builder import build_vpn_connection_resource

client = network_client_factory(cmd.cli_ctx).virtual_network_gateway_connections
DeploymentProperties = cmd.get_models('DeploymentProperties', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
Deployment, DeploymentProperties = cmd.get_models('Deployment', 'DeploymentProperties',
resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
tags = tags or {}

# Build up the ARM template
Expand All @@ -5678,12 +5689,16 @@ def create_vpn_connection(cmd, resource_group_name, connection_name, vnet_gatewa
deployment_name = 'vpn_connection_deploy_' + random_string(32)
client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments
properties = DeploymentProperties(template=template, parameters=parameters, mode='incremental')
deployment = Deployment(properties=properties)
if validate:
from azure.cli.core.commands import LongRunningOperation

_log_pprint_template(template)
return client.validate(resource_group_name, deployment_name, properties)
validation_poller = client.validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)

return sdk_no_wait(no_wait, client.create_or_update,
resource_group_name, deployment_name, properties)
resource_group_name, deployment_name, deployment)


def update_vpn_connection(cmd, instance, routing_weight=None, shared_key=None, tags=None,
Expand Down
50 changes: 35 additions & 15 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ def _deploy_arm_template_core_unmodified(cli_ctx, resource_group_name, template_
template_uri=None, deployment_name=None, parameters=None,
mode=None, rollback_on_error=None, validate_only=False, no_wait=False,
aux_subscriptions=None, aux_tenants=None, no_prompt=False):
DeploymentProperties, TemplateLink, OnErrorDeployment = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'DeploymentProperties', 'TemplateLink',
'OnErrorDeployment', mod='models')
Deployment, DeploymentProperties, TemplateLink, OnErrorDeployment = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'Deployment', 'DeploymentProperties',
'TemplateLink', 'OnErrorDeployment',
mod='models')
template_link = None
template_obj = None
on_error_deployment = None
Expand All @@ -317,6 +318,7 @@ def _deploy_arm_template_core_unmodified(cli_ctx, resource_group_name, template_

properties = DeploymentProperties(template=template_content, template_link=template_link,
parameters=parameters, mode=mode, on_error_deployment=on_error_deployment)
deployment = Deployment(properties=properties)

smc = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, aux_subscriptions=aux_subscriptions,
aux_tenants=aux_tenants)
Expand Down Expand Up @@ -350,14 +352,15 @@ def _deploy_arm_template_core_unmodified(cli_ctx, resource_group_name, template_
sender=PipelineRequestsHTTPSender(RequestsHTTPSender(smc.config))
)

validation_result = deployment_client.validate(resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties)
validation_result_poller = deployment_client.validate(resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=deployment)
validation_result = LongRunningOperation(cli_ctx)(validation_result_poller)

if validation_result and validation_result.error:
raise CLIError(todict(validation_result.error))
if validate_only:
return validation_result

return sdk_no_wait(no_wait, deployment_client.create_or_update, resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, deployment_client.create_or_update, resource_group_name, deployment_name, parameters=deployment)


class JsonCTemplate(object):
Expand All @@ -367,7 +370,7 @@ def __init__(self, template_as_bytes):

class JSONSerializer(Serializer):
def body(self, data, data_type, **kwargs):
if data_type in ('Deployment', 'DeploymentWhatIf'):
if data_type in ('Deployment', 'ScopedDeployment', 'DeploymentWhatIf', 'ScopedDeploymentWhatIf'):
# Be sure to pass a DeploymentProperties
template = data.properties.template
if template:
Expand Down Expand Up @@ -442,9 +445,13 @@ def _deploy_arm_template_at_subscription_scope(cli_ctx,
mode='Incremental',
no_prompt=no_prompt)

Deployment = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'Deployment', mod='models')
deployment = Deployment(properties=deployment_properties, location=deployment_location)

mgmt_client = _get_deployment_management_client(cli_ctx, plug_pipeline=(template_uri is None))

validation_result = mgmt_client.validate_at_subscription_scope(deployment_name=deployment_name, properties=deployment_properties, location=deployment_location)
validation_result_poller = mgmt_client.validate_at_subscription_scope(deployment_name=deployment_name, parameters=deployment)
validation_result = LongRunningOperation(cli_ctx)(validation_result_poller)

if validation_result and validation_result.error:
err_message = _build_preflight_error_message(validation_result.error)
Expand All @@ -453,7 +460,7 @@ def _deploy_arm_template_at_subscription_scope(cli_ctx,
return validation_result

return sdk_no_wait(no_wait, mgmt_client.create_or_update_at_subscription_scope,
deployment_name, deployment_properties, deployment_location)
deployment_name, deployment)


# pylint: disable=unused-argument
Expand Down Expand Up @@ -509,10 +516,14 @@ def _deploy_arm_template_at_resource_group(cli_ctx,
rollback_on_error=rollback_on_error,
no_prompt=no_prompt)

Deployment = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'Deployment', mod='models')
deployment = Deployment(properties=deployment_properties)

mgmt_client = _get_deployment_management_client(cli_ctx, aux_subscriptions=aux_subscriptions,
aux_tenants=aux_tenants, plug_pipeline=(template_uri is None))

validation_result = mgmt_client.validate(resource_group_name=resource_group_name, deployment_name=deployment_name, properties=deployment_properties)
validation_poller = mgmt_client.validate(resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=deployment)
validation_result = LongRunningOperation(cli_ctx)(validation_poller)

if validation_result and validation_result.error:
err_message = _build_preflight_error_message(validation_result.error)
Expand All @@ -521,7 +532,7 @@ def _deploy_arm_template_at_resource_group(cli_ctx,
return validation_result

return sdk_no_wait(no_wait, mgmt_client.create_or_update, resource_group_name,
deployment_name, deployment_properties)
deployment_name, deployment)


# pylint: disable=unused-argument
Expand Down Expand Up @@ -563,9 +574,13 @@ def _deploy_arm_template_at_management_group(cli_ctx,
parameters=parameters, mode='Incremental',
no_prompt=no_prompt)

ScopedDeployment = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'ScopedDeployment', mod='models')
deployment = ScopedDeployment(properties=deployment_properties, location=deployment_location)

mgmt_client = _get_deployment_management_client(cli_ctx, plug_pipeline=(template_uri is None))

validation_result = mgmt_client.validate_at_management_group_scope(group_id=management_group_id, deployment_name=deployment_name, properties=deployment_properties, location=deployment_location)
validation_poller = mgmt_client.validate_at_management_group_scope(group_id=management_group_id, deployment_name=deployment_name, parameters=deployment)
validation_result = LongRunningOperation(cli_ctx)(validation_poller)

if validation_result and validation_result.error:
err_message = _build_preflight_error_message(validation_result.error)
Expand All @@ -574,7 +589,7 @@ def _deploy_arm_template_at_management_group(cli_ctx,
return validation_result

return sdk_no_wait(no_wait, mgmt_client.create_or_update_at_management_group_scope,
management_group_id, deployment_name, deployment_properties, deployment_location)
management_group_id, deployment_name, deployment)


# pylint: disable=unused-argument
Expand Down Expand Up @@ -610,9 +625,13 @@ def _deploy_arm_template_at_tenant_scope(cli_ctx,
parameters=parameters, mode='Incremental',
no_prompt=no_prompt)

ScopedDeployment = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'ScopedDeployment', mod='models')
deployment = ScopedDeployment(properties=deployment_properties, location=deployment_location)

mgmt_client = _get_deployment_management_client(cli_ctx, plug_pipeline=(template_uri is None))

validation_result = mgmt_client.validate_at_tenant_scope(deployment_name=deployment_name, properties=deployment_properties, location=deployment_location)
validation_poller = mgmt_client.validate_at_tenant_scope(deployment_name=deployment_name, parameters=deployment)
validation_result = LongRunningOperation(cli_ctx)(validation_poller)

if validation_result and validation_result.error:
err_message = _build_preflight_error_message(validation_result.error)
Expand All @@ -621,7 +640,7 @@ def _deploy_arm_template_at_tenant_scope(cli_ctx,
return validation_result

return sdk_no_wait(no_wait, mgmt_client.create_or_update_at_tenant_scope,
deployment_name, deployment_properties, deployment_location)
deployment_name, deployment)


def what_if_deploy_arm_template_at_resource_group(cmd, resource_group_name,
Expand Down Expand Up @@ -1081,7 +1100,8 @@ def export_group_as_template(

options = ','.join(export_options) if export_options else None

result = rcf.resource_groups.export_template(resource_group_name, resources, options=options)
result_poller = rcf.resource_groups.export_template(resource_group_name, resources, options=options)
result = LongRunningOperation(cmd.cli_ctx)(result_poller)

# pylint: disable=no-member
# On error, server still returns 200, with details in the error attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"nestedsubId": {
"value": "0b1f6471-1bf0-4dda-aec3-cb9272f09590"
"value": "a93e8c5c-63cb-4635-933f-6d166ac25187"
},
"storageAccountName": {
"value": "armbuilddemo1234"
"value": "armbuilddemo2345"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetMG": {
Expand Down
Loading