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
5 changes: 5 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Release History
===============

0.5.13
+++++
* Add compatible logic for the track 2 migration of resource dependence

0.5.12
+++++
* Add --enable-azure-rbac and --disable-azure-rbac in aks update
Expand Down
49 changes: 22 additions & 27 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,16 @@ def _invoke_deployment(cmd, resource_group_name, deployment_name, template, para
logger.info(json.dumps(template, indent=2))
logger.info('==== END TEMPLATE ====')

if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
Deployment = cmd.get_models(
'Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)

if validate:
validation_poller = smc.validate(
resource_group_name, deployment_name, deployment)
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)
if validate:
if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
validation_poller = smc.begin_validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, deployment)
else:
return smc.validate(resource_group_name, deployment_name, deployment)

if validate:
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)
return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)


def create_application(client, display_name, homepage, identifier_uris,
Expand Down Expand Up @@ -2598,29 +2594,27 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
resource_groups = cf_resource_groups(cmd.cli_ctx, subscription_id)
resources = cf_resources(cmd.cli_ctx, subscription_id)

from azure.cli.core.profiles import ResourceType
# check if default RG exists
if resource_groups.check_existence(default_workspace_resource_group):
from azure.core.exceptions import HttpResponseError
try:
resource = resources.get_by_id(
default_workspace_resource_id, '2015-11-01-preview')
return resource.id
except CloudError as ex:
except HttpResponseError as ex:
if ex.status_code != 404:
raise ex
else:
resource_groups.create_or_update(default_workspace_resource_group, {
'location': workspace_region})

default_workspace_params = {
'location': workspace_region,
'properties': {
'sku': {
'name': 'standalone'
}
}
}
async_poller = resources.create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
default_workspace_params)
ResourceGroup = cmd.get_models('ResourceGroup', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
resource_group = ResourceGroup(location=workspace_region)
resource_groups.create_or_update(default_workspace_resource_group, resource_group)

GenericResource = cmd.get_models('GenericResource', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
generic_resource = GenericResource(location=workspace_region, properties={'sku': {'name': 'standalone'}})

async_poller = resources.begin_create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
generic_resource)

ws_resource_id = ''
while True:
Expand Down Expand Up @@ -2669,11 +2663,12 @@ def _ensure_container_insights_for_monitoring(cmd, addon):

# region of workspace can be different from region of RG so find the location of the workspace_resource_id
resources = cf_resources(cmd.cli_ctx, subscription_id)
from azure.core.exceptions import HttpResponseError
try:
resource = resources.get_by_id(
workspace_resource_id, '2015-11-01-preview')
location = resource.location
except CloudError as ex:
except HttpResponseError as ex:
raise ex

unix_time_in_millis = int(
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open as open1
from setuptools import setup, find_packages

VERSION = "0.5.12"
VERSION = "0.5.13"
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
4 changes: 4 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.1.4
++++++
* Add compatible logic for the track 2 migration of resource dependence

1.1.3
++++++
* Fix for list_node() sdk function for AKS v1.19.x clusters
Expand Down
6 changes: 4 additions & 2 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ def create_connectedk8s(cmd, client, resource_group_name, cluster_name, https_pr

# Resource group Creation
if resource_group_exists(cmd.cli_ctx, resource_group_name, subscription_id) is False:
resource_group_params = {'location': location}
from azure.cli.core.profiles import ResourceType
ResourceGroup = cmd.get_models('ResourceGroup', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another place where we use ResourceType.MGMT_RESOURCE_RESOURCES.

groups = cf_resource_groups(ctx, subscription_id=subscription_id)

imported from:
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know it. However, there is no breaking change in this logic, so no additional compatibility logic is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the breaking changes in the new azure-mgmt-resource SDK, please refer to the description of PR Azure/azure-cli#17783

parameters = ResourceGroup(location=location)
try:
resourceClient.resource_groups.create_or_update(resource_group_name, resource_group_params)
resourceClient.resource_groups.create_or_update(resource_group_name, parameters)
Copy link
Contributor

@akashkeshari akashkeshari May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are also using the resourceClient here:

providerDetails = resourceClient.providers.get('Microsoft.Kubernetes')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reminder~ In fact, I know it. However, there is no breaking change for this operation (code link), so no additional compatibility logic is required.

except Exception as e: # pylint: disable=broad-except
utils.arm_exception_handler(e, consts.Create_ResourceGroup_Fault_Type, 'Failed to create the resource group')

Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '1.1.3'
VERSION = '1.1.4'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
4 changes: 4 additions & 0 deletions src/db-up/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.2.3 (2021-05-10)
++++++++++++++++++
* Add compatible logic for the track 2 migration of resource dependence

0.2.2 (2021-03-22)
++++++++++++++++++
* Configure for custom cloud settings
Expand Down
2 changes: 1 addition & 1 deletion src/db-up/azext_db_up/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def server_down(cmd, client, resource_group_name=None, server_name=None, delete_

# delete resource group
logger.warning('Deleting Resource Group \'%s\'...', resource_group_name)
return resource_client.resource_groups.delete(resource_group_name)
return resource_client.resource_groups.begin_delete(resource_group_name)
logger.warning('Deleting server \'%s\'...', server_name)
return client.delete(resource_group_name, server_name)

Expand Down
2 changes: 1 addition & 1 deletion src/db-up/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "0.2.2"
VERSION = "0.2.3"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
5 changes: 5 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.4.1
++++++++++++++++++

* Add compatible logic for the track 2 migration of resource dependence

0.4.0
++++++++++++++++++

Expand Down
3 changes: 2 additions & 1 deletion src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, clus
"Error! Cluster type '{}' is not supported for extension identity".format(cluster_type)
)

from azure.core.exceptions import HttpResponseError
try:
resource = resources.get_by_id(cluster_resource_id, parent_api_version)
location = str(resource.location.lower())
except CloudError as ex:
except HttpResponseError as ex:
raise ex
identity_type = "SystemAssigned"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,16 @@ def _invoke_deployment(cmd, resource_group_name, deployment_name, template, para
logger.info(json.dumps(template, indent=2))
logger.info('==== END TEMPLATE ====')

if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
deployment_temp = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = deployment_temp(properties=properties)

if validate:
validation_poller = smc.validate(resource_group_name, deployment_name, deployment)
deployment_temp = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = deployment_temp(properties=properties)
if validate:
if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
validation_poller = smc.begin_validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, deployment)
else:
return smc.validate(resource_group_name, deployment_name, deployment)

if validate:
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)
return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call in begin_create_or_update is failing. It is coming with ERROR: 'DeploymentsOperations' object has no attribute 'begin_create_or_update'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the upgrade of azure-mgmt-resource in CLI main repo has not been released, it can only be tested through the dev environment. So may I ask if you are using CLI in dev environment and pulled the latest code from remote dev branch?
The expected version of azure-mgmt-resource is 16.1.0, please execute pip list to confirm whether the version is correct~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathan-innis May I ask can you pass the test now?



def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
Expand Down Expand Up @@ -201,6 +199,9 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
"usgovvirginia": "usgovvirginia"
}

from azure.core.exceptions import HttpResponseError
from azure.cli.core.profiles import ResourceType

cluster_location = ''
resources = cf_resources(cmd.cli_ctx, subscription_id)

Expand All @@ -209,7 +210,7 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
try:
resource = resources.get_by_id(cluster_resource_id, '2020-01-01-preview')
cluster_location = resource.location.lower()
except CloudError as ex:
except HttpResponseError as ex:
raise ex

cloud_name = cmd.cli_ctx.cloud.name.lower()
Expand Down Expand Up @@ -261,23 +262,18 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
try:
resource = resources.get_by_id(default_workspace_resource_id, '2015-11-01-preview')
return resource.id
except CloudError as ex:
except HttpResponseError as ex:
if ex.status_code != 404:
raise ex
else:
resource_groups.create_or_update(default_workspace_resource_group, {
'location': workspace_region})

default_workspace_params = {
'location': workspace_region,
'properties': {
'sku': {
'name': 'standalone'
}
}
}
async_poller = resources.create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
default_workspace_params)
ResourceGroup = cmd.get_models('ResourceGroup', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
resource_group = ResourceGroup(location=workspace_region)
resource_groups.create_or_update(default_workspace_resource_group, resource_group)

GenericResource = cmd.get_models('GenericResource', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
generic_resource = GenericResource(location=workspace_region, properties={'sku': {'name': 'standalone'}})
async_poller = resources.begin_create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
generic_resource)

ws_resource_id = ''
while True:
Expand All @@ -294,11 +290,12 @@ def _ensure_container_insights_for_monitoring(cmd, workspace_resource_id):
parsed = parse_resource_id(workspace_resource_id)
subscription_id, resource_group = parsed["subscription"], parsed["resource_group"]

from azure.core.exceptions import HttpResponseError
resources = cf_resources(cmd.cli_ctx, subscription_id)
try:
resource = resources.get_by_id(workspace_resource_id, '2015-11-01-preview')
location = resource.location
except CloudError as ex:
except HttpResponseError as ex:
raise ex

unix_time_in_millis = int(
Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "0.4.0"
VERSION = "0.4.1"

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand Down
6 changes: 6 additions & 0 deletions src/mesh/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Release History
===============

0.10.7 (2021-5-10)
++++++++++++++++++

* Add compatible logic for the track 2 migration of resource dependence

0.10.6 (2019-6-24)
++++++++++++++++++

Expand Down
22 changes: 15 additions & 7 deletions src/mesh/azext_mesh/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@ def _generate_arm_template_core(input_yaml_files=None, parameters=None):
logger.warning("Generated ARM template file at %s.", output_file_path)


def _deploy_arm_template_core(cli_ctx, resource_group_name, # pylint: disable=too-many-arguments
def _deploy_arm_template_core(cmd, resource_group_name, # pylint: disable=too-many-arguments
template_file=None, template_uri=None, input_yaml_files=None, deployment_name=None,
parameters=None, mode=None, validate_only=False,
no_wait=False):
DeploymentProperties, TemplateLink = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'DeploymentProperties', 'TemplateLink', mod='models')
DeploymentProperties, TemplateLink, Deployment = get_sdk(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
'DeploymentProperties', 'TemplateLink', 'Deployment',
mod='models')

template = None
template_link = None
template_obj = None
Expand Down Expand Up @@ -275,21 +277,27 @@ def _deploy_arm_template_core(cli_ctx, resource_group_name, # pylint: disable=t
parameters=parameters, mode=mode)
# workaround
properties.mode = 'incremental'
smc = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
smc = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments
deployment = Deployment(properties=properties)

logger.warning("Deploying . . .")
logger.warning("You can get the state of the deployment with the cmd")
logger.warning("az group deployment show --name %s --resource-group %s", deployment_name, resource_group_name)
if validate_only:
return sdk_no_wait(no_wait, smc.deployments.validate, resource_group_name, deployment_name, properties)
if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
from azure.cli.core.commands import LongRunningOperation
validation_poller = smc.begin_validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)
else:
return sdk_no_wait(no_wait, smc.validate, resource_group_name, deployment_name, deployment)

return sdk_no_wait(no_wait, smc.deployments.create_or_update, resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)


def deploy_arm_template(cmd, resource_group_name,
template_file=None, template_uri=None, input_yaml_files=None, deployment_name=None,
parameters=None, mode=None, no_wait=False):
return _deploy_arm_template_core(cmd.cli_ctx, resource_group_name, template_file, template_uri,
return _deploy_arm_template_core(cmd, resource_group_name, template_file, template_uri,
input_yaml_files, deployment_name, parameters, mode, no_wait=no_wait)


Expand Down
2 changes: 1 addition & 1 deletion src/mesh/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "0.10.6"
VERSION = "0.10.7"


CLASSIFIERS = [
Expand Down
5 changes: 5 additions & 0 deletions src/service_name.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@
"AzureServiceName": "Azure Spring Cloud",
"URL": "https://docs.microsoft.com/azure/spring-cloud/"
},
{
"Command": "az sql",
"AzureServiceName": "Azure SQL",
"URL": "https://docs.microsoft.com/en-us/azure/azure-sql/"
},
{
"Command": "az ssh",
"AzureServiceName": "Azure Virtual Machines",
Expand Down