[ARM] az deployment group create: Fix the compatibility issue of api-version for parameter --template-specs#17896
Merged
zhoxing-ms merged 8 commits intoAzure:devfrom Apr 28, 2021
Conversation
3 tasks
wiebeck
suggested changes
Apr 27, 2021
added 3 commits
April 27, 2021 16:08
zhoxing-ms
reviewed
Apr 28, 2021
Comment on lines
+894
to
+896
| elif template_spec: | ||
| template_link = TemplateLink(id=template_spec, mode="Incremental") | ||
| template_obj = show_resource(cmd=cmd, resource_ids=[template_spec]).properties['template'] | ||
| resource = show_resource(cmd=cmd, resource_ids=[template_spec]) |
Contributor
There was a problem hiding this comment.
If this logic is only for template_spec, could we specify the api-version to ResourceType.MGMT_RESOURCE_TEMPLATESPECS here? Otherwise, it will use the latest version and may be inconsistent with ResourceType.MGMT_RESOURCE_TEMPLATESPECS
In this way, we can ensure that the api-versions of all the rest requests for template_spec are consistent in the same profile
Contributor
There was a problem hiding this comment.
Such as:
from azure.cli.core.profiles import get_api_version
api_version = get_api_version(cli_ctx, ResourceType.MGMT_RESOURCE_TEMPLATESPECS)
template_obj = show_resource(cmd=cmd, resource_ids=[template_spec], api_version=api_version).properties['template']
added 2 commits
April 27, 2021 23:11
zhoxing-ms
approved these changes
Apr 28, 2021
az deployment group create: Fix the compatibility issue of api-version for parameter --template-specs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
""
Deploying template specs currently does not work. The API version 2021-03-01-preview returns a template spec with mainTemplate as part of properties while the code in src/azure-cli/azure/cli/command_modules/resource/custom.py tries to access key template which has been the name of the key in API version 2019-06-01-preview.
_This PR fixes #17733
The code contains other places where dict key template is being referenced but I am unsure whether this plays a role for this particular case (deploy a template spec version).
Testing Guide
See #17733 for a detailed explanation, especially this comment by @tonystz.
""
- From (#17893)
From my ongoing investigation (#17893) is not the proper fix for this. I was able to repro this issue and the key points to notice from the --debug output are :
A. { Request URL: 'https://management.azure.com/subscriptions/a1bfa635-f2bf-42f1-86b5-848c674fc321/providers/Microsoft.Resources?api-version=2020-10-01' }
B. { Request URL: 'https://management.azure.com/subscriptions/a1bfa635-f2bf-42f1-86b5-848c674fc321/resourceGroups/TemplateSpecsCLI/providers/Microsoft.Resources/templateSpecs/BugTest/versions/1.0?api-version=2021-03-01-preview' }
Azure CLI currently points to Microsoft.Resources version 2020-10-01 and Template Specs 2019-06-01-preview. It looks this PR:
( https://github.com/Azure/azure-rest-api-specs/pull/13811}
may have caused Microsoft.Resources version 2020-10-01 to be updated to use the latest (template-spec) client(s). This means that 'az deployment group create --template-spec' is now using template spec 2021-03-01-preview instead of 2019-06-01-preview as it should be.
This has caused a regression in Azure CLI. The code is CLI has not been updated for 2021-03-01 preview which has a few breaking changes for template specs; most notably the 'template' property has been replaced by 'main_template'. As a result the code in the CLI attempts to retrieve the 'template' property from the --template-spec input and fails.
Although the TemplateSpecs API will be update for CLI when a proper SDK release for Python is done (Azure/sdk-release-request#1469) , (ref: https://github.com/Azure/azure-cli/pull/17869/files) in the meantime I will send a fix for this and notify swagger team of the issue so they may prevent it in the future.