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

[ARM] az ts: Add new commands for template specs ; [ARM] az deployment : Add support for --template-spec -s #14448

Merged
merged 173 commits into from
Sep 24, 2020
Merged

[ARM] az ts: Add new commands for template specs ; [ARM] az deployment : Add support for --template-spec -s #14448

merged 173 commits into from
Sep 24, 2020

Conversation

detienne20
Copy link
Contributor

@detienne20 detienne20 commented Jul 21, 2020

Description

This PR enables template specs (ts) commands to create, update, list, show, export, and delete template specs. Also added is support for template-specs with Az CLI Deployment. Microsoft.Resources is updated to use the latest Python SDK. The latest Python SDK required some functions to take in different parameters and account for different return types. All test cases involving template-spec have been updated (i.e--template-specs are now created dynamically for az deployment tests).

Note: #14241 has been closed. This PR would include/override the changes made there.

Testing Guide

az ts

Create:

      az ts create -g testRG --name TemplateSpecName -l WestUS --display-name 
        "MyDisplayName" --description "Simple template spec"

      az ts create -g testRG -n TemplateSpecName -v 1.0 -l WestUS
          --f templateSpec.json --display-name "SimpleTemplate" --description "Basic 
           template spec"  --version-description "Version of basic template spec"

Update:

    az ts create -g testrg -n MyTemplateSpecName  -v 1.0 -f updatedFile.json
   
    az ts update -s resourceID -f updatedTemplate.json

    az ts update -g ExistingRG -n ExistingName -v 3.0 -f updatedTemplate.json 
        -d "New parent display name"  --description "New parent description" 
        --version-description "New child description"

Show:

    az ts show -s resourceID

    az ts show-g testrg --name TemplateSpecName

    az ts show -g testrg --name TemplateSpecName --version VersionName

List:

    az ts list

    az ts list -g SpecifiedResourceGroup

    az ts list --subscription SpecifiedSubscription
     
    az ts list -g testRG -n ParentTemplateSpecName

Export:

   az ts export -g testrg --name TemplateSpecName --version VersionName -- 
     output-folder C:/path/

   az ts export -s resourceID --output-folder C:/path/

   az ts export -g testrg --name TemplateSpecName --output-folder C:/path/

Delete:

   az ts delete --template-spec resourceID

   az ts delete -g MyResourceGroup --name TemplateSpecName

   az ts delete -g MyResourceGroup --name TemplateSpecName --version 
     VersionName

Az Deployments with --template-spec

Resource Group:

  az deployment group validate --resource-group "resource-group-name" --template-spec 
    resource-id-to-template-spec

  az deployment group create --resource-group "resource-group-name" --template-spec 
    resource-id-to-template-spec
 
  az deployment group what-if --resource-group testrg --template-spec resource-id-to-template-spec  
     --parameters @myparameters.json  --no-pretty-print'

Subscription Scope:

  az deployment sub validate --location WestUS --template-spec resource-id-to-template-spec

  az deployment sub create --location WestUS --template-spec resource-id-to-template-spec

  az deployment sub what-if --resource-group testRG --template-spec resource-id-to-template-spec  
     --parameters https://mysite/params.json --parameters MyValue=This [email protected]  
     --no-pretty-print

Management Group:

 az deployment mg validate --management-group-id testmgmt --location WestUS --template-spec 
    resource-id-to-template-spec

 az deployment mg create --management-group-id testmgmt --location WestUS --template-spec 
    resource-id-to-template-spec
 
  az deployment mg what-if --resource-group testRG --template-spec resource-id-to-template-spec  
     --parameters '{ \"policyName\": { \"value\": \"policy2\" } }  --no-pretty-print'

Tenant-Scope:

 az deployment tenant validate --location WestUS --template-spec resource-id-to-template-spec

 az deployment tenant create --location WestUS --template-spec resource-id-to-template-spec

 az deployment tenant what-if --resource-group testRG --template-spec resource-id-to-template-spec  
     --parameters https://mysite/params.json --parameters MyValue=This [email protected]  
     --no-pretty-print'

History Notes

dkmiller and others added 30 commits April 27, 2020 16:13
…e stamp added to deployment_name, excess file removed in commit, launch,json reverted
Copy link
Member

@jiasli jiasli left a comment

Choose a reason for hiding this comment

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

Core LGTM.

@zhoxing-ms zhoxing-ms merged commit b232ed9 into Azure:dev Sep 24, 2020
Juliehzl pushed a commit to Juliehzl/azure-cli that referenced this pull request Sep 30, 2020
…t : Add support for --template-spec -s (Azure#14448)

* {Docs} Remove stale reference in README to closed issue about extensions (Azure#12771)

* Preliminary changes made to add support for template-specs

* Reconfiguration

* validate function error rectified

* validate command works for template-uri

* Template-specs deployment works at resource-group level

* Group deployment updated to function with 2020 SDK

* validate with template specs added

* Management scope and tenant scope errors fixed

* Template-Specs Deployment Added

* Template-Specs Deployment Added

* Updated test cases and removed unnecessary comments

* Removed test cases from launch.json

* Uncommented test case

* Cleaned up repo

* Cleaned up repo

* Style checks complete, template_spec parameter placed at the end, time stamp added to deployment_name, excess file removed in commit, launch,json reverted

* Fixed failing CLI Check Test

* Merged with /dev

* Added template-specs command group, added help

* Create or update template spec functioning

* packing engine packing mechanism complete

* Template-Specs CRUD Implemented, Artifacts has full support, added test cases and testing files

* Updated template-specs CRUD tests and template-specs deployment-tests

* Updated all tests for template-specs

* Updated tests

* Fixed style and linter

* Uncommented test case

* Fixed linter resource:

* merged with dev

* merged

* Fixed merge errors

* Fixed json parsing errors

* Revert changed deployment name

* Revert changed deployment name

* deleted extra deployment object causing bot error

* Revered launch.json changes

* Removed unnecessary changes

* Reinstalled requirements, fixed resource linter and style

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Xing Zhou <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Xing Zhou <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/resource/_validators.py

Co-authored-by: Xing Zhou <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Xing Zhou <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Xing Zhou <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Xing Zhou <[email protected]>

* Small syntax suggested by reviewers made

* Removed unnecessary changes in test_resource

* Merged recordings

* Changed python path in launch.json

* recorded deployment tests for template-specs

* Recorded template-specs CRUD

* TemplateSpecs is a live test

* Tests are updated to latest

* Commands now work with 10.1.0

* Updated what if parameters

* Fixed style and linter

* acs tests restored

* Removed unnecessary changes

* Restored launch.json

* added git ignore back in

* Bot_template restored

* removed unnecessary comment

* Updated web app folderto new one

* revereted

* Syntax changes for function names in packing_engine

* launch.json issue

* changed to new sdk release

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Shenglong Li <[email protected]>

* Update src/azure-cli/azure/cli/command_modules/resource/_help.py

Co-authored-by: Shenglong Li <[email protected]>

* Made recommended changes

* snake_case for _packing_engine

* Restored network tests

* Fixed CLI Linter

* Small syntax errors fixed

* reverted launch.json changes

* Deleted local context file

* Updated get template-specs

* Updated get template-specs

* changed validator logic, added tests for template-specs list, changed get template-specs to show template-specs, updated help commands, removed tag commands

* changed validator

* Fixed validators

* Fix getting resource API version in ARM cmdlt

Latest swagger updates added the 'defaultApiVersion' property to the GET resource providers response.
The old code was trying to use the default API version and only than fall back to the API versions specified in the manifest.
This was wrong because:
1. default API version was not part of the response (until the latest SDK update), so this code was not doing anything
2. default API versions can be null
3. default API version is mostly used for internal purposes and must be included in the list of available API versions.

This change address this issue.

* Changed validators, added what_if test for template_specs

* Fixed linter and style resource

* Update sample_policy_set.json

* Update sample_policy_set.json

* Update sample_policy_set_parameterized.json

* Allows string for --template-spec parameter

* template-spec validators updated

* Better error handling for deployment

* merged with dev, updated template-specs command module name to ts

* Fixed style

* Added temporary fix for preview message bug for private preview

* Different bug fix attempt

* Removed unnecessary changes in preparation for merge

* Update src/azure-cli-core/azure/cli/core/commands/__init__.py

Co-authored-by: Jiashuo Li <[email protected]>

* restored new line at end of files

* restored new line at end of files

* restored no new line at end of files

* restored no new line at end of files

* min_api added

* Template Specs no longer a live test

* New build for recent changes committed to dev

* Resource type for template specs changed to profiel type

* Export template specs is a live scenario test

* restored launch.json

* restored launch.json

* removed export test folder

* Reduced repetitive code in _help.py

* Fixed trailing white spaces and added new line at end of _params.py

* set a default version in other profiles for ResourceType.MGMT_RESOURCE_TEMPLATESPECS before 2019-06-01-preview, so that the judgment logic of min_api is based on ResourceType.MGMT_RESOURCE_TEMPLATESPECS. as requested

* Update launch.json

Co-authored-by: Daniel Miller <[email protected]>
Co-authored-by: Azure CLI Team <[email protected]>
Co-authored-by: Dania Etienne <[email protected]>
Co-authored-by: Xing Zhou <[email protected]>
Co-authored-by: Shenglong Li <[email protected]>
Co-authored-by: Elad Perets <[email protected]>
Co-authored-by: Jiashuo Li <[email protected]>
@detienne20 detienne20 deleted the daetienn/template-spec-crud branch December 2, 2020 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.