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 stack: Add new commands for deployment stacks #24211

Merged
merged 204 commits into from
Jun 28, 2023

Conversation

harshpatel17
Copy link
Contributor

@harshpatel17 harshpatel17 commented Oct 14, 2022

Description

This PR enables deployment stack (stacks) commands to create, list, export, show, and delete deployment stacks on subscription, resource group scopes or management scopes.

Testing Guide

az stack

  • sub
    • create
    • show
    • list
    • delete
    • export
  • group
    • create
    • show
    • list
    • delete
    • export
  • mg
    • create
    • show
    • list
    • delete
    • export

stack sub

az stack sub create
short-summary: Create a deployment stack at subscription scope
examples:

  • name: Create a deployment stack using template file.
    az stack sub create --name "StackName" c --template-file simpleTemplate.json --location "westus2" --description "description"
  • name: Create a deployment stack with parameter file.
    az stack sub create --name "StackName" --update-behavior "detachResources" --template-file simpleTemplate.json --parameters simpleTemplateParams.json --location "westus2" --description "description"
  • name: Create a deployment stack with template spec
    az stack sub create --name "StackName" --update-behavior "detachResources" --template-spec "TemplateSpecResourceIDWithVersion" --location "westus2" --description "description"
  • name: Create a deployment stack using bicep file.
    az stack sub create --name "StackName" --update-behavior "detachResources" --template-file simple.bicep --location "westus2" --description "description"
  • name: Create a deployment stack at a different subscription.
    az stack sub create --name "StackName" --update-behavior "detachResources" --template-file simpleTemplate.json --location "westus2" --description "description --subscription "subscriptionId"
  • name: Create a deployment stack and deploy at the resource group scope.
    az stack sub create --name "StackName" --template-file simpleTemplate.json --location "westus" --resource-group "ResourceGroup" --description "description"
  • name: Create a deployment stack using parameters from key/value pairs
    az stack sub create --name "StackName" --template-file simpleTemplate.json --location "westus" --description "description" --parameters simpleTemplateParams.json value1=foo value2=bar
  • name: Create a deployment stack from a local template, using a parameter file, a remote parameter file, and selectively overriding key/value pairs.
    az stack sub create --name rollout01 --template-file azuredeploy.json --parameters @params.json --parameters https://mysite/params.json --parameters MyValue=This MyArray=@array.json --location "westus"
  • name: Create a deployment stack from a local template, using deny settings.
    az stack sub create --name rollout01 --template-file azuredeploy.json --deny-settings-mode "denyDelete" --deny-settings-excluded-actions "Microsoft.Compute/virtualMachines/write" --deny-settings-excluded-principals "test1 test2" --location "westus"
  • name: Create a deployment stack from a local template, apply deny settings to child scopes.
    az stack sub create --name rollout01 --template-file azuredeploy.json --deny-settings-mode "denyDelete" --deny-settings-excluded-actions "Microsoft.Compute/virtualMachines/write" --deny-settings-apply-to-child-scopes --location "westus"

az stack sub list
short-summary: Show all deployment stacks in subscription
examples:

  • name: List all stacks
    az stack sub list

az stack sub show
short-summary: Get specified deployment stack from subscription scope
examples:

  • name: Get stack by name.
    az stack sub show --name "StackName"
  • name: Get stack by stack resource id.
    az stack sub show --id "StackResourceID"

az stack sub delete
short-summary: Delete specified deployment stack from subscription scope
examples:

  • name: Delete stack by name.
    az stack sub delete --name "StackName"
  • name: Delete stack by stack resource id.
    az stack sub delete --id "StackResourceID"

az stack sub export
short-summary: Exports the template used to create the deployment stack
examples:

  • name: Export template by name.
    az stack sub export --name "StackName"
  • name: Export template by stack resource id.
    az stack sub export --id "StackResourceID"

stacks group

az stack group create
short-summary: Create a deployment stack at resource group scope
examples:

  • name: Create a deployment stack using template file.
    az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simpleTemplate.json --description "description"
  • name: Create a deployment stack with parameter file.
    az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simpleTemplate.json --parameters simpleTemplateParams.json --description "description"
  • name: Create a deployment stack with template spec
    az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-spec "TemplateSpecResourceIDWithVersion" --description "description"
  • name: Create a deployment stack using bicep file.
    az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simple.bicep --description "description"
  • name: Create a deployment stack at a different subscription
    az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simpleTemplate.json --description "description --subscription "subscriptionId"
  • name: Create a deployment stack using parameters from key/value pairs
    az stack group create --name "StackName" --template-file simpleTemplate.json --resource-group "ResourceGroup" --description "description" --parameters simpleTemplateParams.json value1=foo value2=bar
  • name: Create a deployment stack from a local template, using a parameter file, a remote parameter file, and selectively overriding key/value pairs.
    az stack group create --name rollout01 --template-file azuredeploy.json --parameters @params.json --parameters https://mysite/params.json --parameters MyValue=This MyArray=@array.json --resource-group "ResourceGroup"
  • name: Create a deployment stack from a local template, using deny settings.
    az stack group create --name rollout01 --resource-group "ResourceGroup" --template-file azuredeploy.json --deny-settings-mode "denyDelete" --deny-settings-excluded-actions "Microsoft.Compute/virtualMachines/write" --deny-settings-excluded-principals "test1 test2"
  • name: Create a deployment stack from a local template, apply deny setting to child scopes.
    az stack group create --name rollout01 --resource-group "ResourceGroup" --template-file azuredeploy.json --deny-settings-mode "denyDelete" --deny-settings-excluded-actions "Microsoft.Compute/virtualMachines/write" --deny-settings-apply-to-child-scopes

az stack group list
short-summary: Show all deployment stacks in resource group
examples:

  • name: List all stacks in resource group
    az stack group list --resource-group "ResourceGroup"

az stack group show
short-summary: Get specified deployment stack from resource group scope
examples:

  • name: Get stack by name.
    az stack group show --name "StackName" --resource-group "ResourceGroup"
  • name: Get stack by stack resource id.
    az stack group show --id "StackResourceID"

az stack group delete
short-summary: Delete specified deployment stack from resource group scope
examples:

  • name: Delete stack by name.
    az stack group delete --name "StackName" --resource-group "ResourceGroup"
  • name: Delete stack by stack resource id.
    az stack group delete --id "StackResourceID"

az stack group export
short-summary: Exports the template used to create the deployment stack from resource group scope
examples:

  • name: Export template by name.
    az stack group export --name "StackName" --resource-group "ResourceGroup"
  • name: Export template by stack resource id.
    az stack group export --id "StackResourceID"

stacks mg

az stack mg create
short-summary: Create a deployment stack at management group scope
examples:

  • name: Create a deployment stack using template file.
    az stack mg create --name "StackName" --management-group-id myMg --template-file simpleTemplate.json --location "westus2" --description "description"
  • name: Create a deployment stack with parameter file.
    az stack mg create --name "StackName" --management-group-id myMg --update-behavior "detachResources" --template-file simpleTemplate.json --parameters simpleTemplateParams.json --location "westus2" --description "description"
  • name: Create a deployment stack with template spec
    az stack mg create --name "StackName" --management-group-id myMg --update-behavior "detachResources" --template-spec "TemplateSpecResourceIDWithVersion" --location "westus2" --description "description"
  • name: Create a deployment stack using bicep file.
    az stack mg create --name "StackName" --management-group-id myMg --update-behavior "detachResources" --template-file simple.bicep --location "westus2" --description "description"
  • name: Create a deployment stack using parameters from key/value pairs
    az stack mg create --name "StackName" --management-group-id myMg --template-file simpleTemplate.json --location "westus" --description "description" --parameters simpleTemplateParams.json value1=foo value2=bar
  • name: Create a deployment stack from a local template, using a parameter file, a remote parameter file, and selectively overriding key/value pairs.
    az stack mg create --name rollout01 --management-group-id myMg --template-file azuredeploy.json --parameters @params.json --parameters https://mysite/params.json --parameters MyValue=This MyArray=@array.json --location "westus"
  • name: Create a deployment stack from a local template, using deny settings.
    az stack mg create --name rollout01 --management-group-id myMg --template-file azuredeploy.json --deny-settings-mode "denyDelete" --deny-settings-excluded-actions "Microsoft.Compute/virtualMachines/write" --deny-settings-excluded-principals "test1 test2" --location "westus"
  • name: Create a deployment stack from a local template, apply deny settings to child scope.
    az stack mg create --name rollout01 --management-group-id myMg --template-file azuredeploy.json --deny-settings-mode "denyDelete" --deny-settings-excluded-actions "Microsoft.Compute/virtualMachines/write" --deny-settings-apply-to-child-scopes --location "westus"

az stack mg list
short-summary: List all deployment stacks in management group
examples:

  • name: List all stacks
    az stack mg list ----management-group-id myMg

az stack mg show
short-summary: Get specified deployment stack from management group scope
examples:

  • name: Get stack by name.
    az stack mg show --name "StackName" --management-group-id myMg
  • name: Get stack by stack resource id.
    az stack mg show --id "StackResourceID" --management-group-id myMg

az stack mg delete
short-summary: Delete specified deployment stack from management group scope
examples:

  • name: Delete stack by name.
    az stack mg delete --name "StackName" --management-group-id myMg
  • name: Delete stack by stack resource id.
    az stack mg delete --id "StackResourceID" --management-group-id myMg

az stack mg export
short-summary: Exports the template used to create the deployment stack
examples:

  • name: Export template by name.
    az stack mg export --name "StackName" --management-group-id myMg
  • name: Export template by stack resource id.
    az stack mg export --id "StackResourceID" --management-group-id myMg

History Notes

[ARM] az stack: Add new command group to support deployment stacks
[ARM] az stack mg: Add new command group to manage deployment stack at management group scope
[ARM] az stack sub: Add new command group to manage deployment stack at subscription scope
[ARM] az stack group: Add new command group to manage deployment stack at resource group scope


This checklist is used to make sure that common guidelines for a pull request are followed.

Harsh Patel and others added 30 commits August 26, 2021 16:50
@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jun 26, 2023

ERROR: Can not find 'stack mg create --template-spec' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --template-uri' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --query-string' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --description' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --deployment-subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --delete-all' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --deny-settings-excluded-principals' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --deny-settings-excluded-actions' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --deny-settings-apply-to-child-scopes' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg create --tags' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg show --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg export --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg show --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg export --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg delete --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg delete --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg delete --delete-all' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack mg list --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --template-uri' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --query-string' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --description' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --deny-settings-excluded-principals' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --deny-settings-excluded-actions' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --deny-settings-apply-to-child-scopes' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub create --tags' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub show --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub export --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub show --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub export --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub delete --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack sub delete --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --template-uri' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --query-string' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --description' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --delete-resource-groups' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --deny-settings-excluded-principals' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --deny-settings-excluded-actions' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --deny-settings-apply-to-child-scopes' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group create --tags' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group show --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group export --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group show --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group export --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group list --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group delete --name,' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group delete --subscription' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml
ERROR: Can not find 'stack group delete --delete-resource-groups' test case
ERROR: Please add some scenario tests for the new parameter
ERROR: Or add the parameter with missing_parameter_test_coverage rule in linter_exclusions.yml

From the error log of the CI pipeline pipeline link, we can see that 49 parameters were not tested, resulting in the missing_command_test_coverage error. If the restrictions on parameter level are too strict? Could we modify the linter rule to the command level? @wangzelin007

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jun 26, 2023

@harshpatel17 Please refer to the guideline to write the description of those PR changes in the History Notes section of PR description. Please note that it will be synced to the release notes of CLI. Such as #26261
image

template_obj = _remove_comments_from_json(_urlretrieve(t_uri).decode('utf-8'), file_path=t_uri)
else:
if _is_bicepparam_file_provided(parameters):
ensure_bicep_installation(cmd.cli_ctx)
Copy link
Contributor

@zhoxing-ms zhoxing-ms Jun 27, 2023

Choose a reason for hiding this comment

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

E vcr.errors.CannotOverwriteExistingCassetteException: Can't overwrite existing cassette ('/mnt/vss/_work/1/s/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_deployment_stack_resource_group.yaml') in your current record mode ('once').
No match for the request (<Request (GET) https://downloads.bicep.azure.com/v0.18.4/bicep-linux-x64>) was found.
Found 1 similar requests with 1 different matcher(s) :
1 - (<Request (GET) https://downloads.bicep.azure.com/releases/latest>).
Matchers succeeded : ['method', 'scheme', 'host', 'port', '_custom_request_query_matcher']
Matchers failed :
path - assertion failure :
/v0.18.4/bicep-linux-x64 != /releases/latest

In the CI pipeline, since the ensure_bicep_installation method uses the get_bicep_latest_release_tag method to obtain the release tag for Bicep CLI, the current release tag from https://aka.ms/BicepLatestRelease is v0.18.4.

The _get_bicep_download_url method will calculate the download URL of Bicep CLI as https://downloads.bicep.azure.com/v0.18.4/bicep-linux-x64

def _get_bicep_download_url(system, release_tag, target_platform=None):
download_url = f"https://downloads.bicep.azure.com/{release_tag}/{{}}"
if target_platform:
executable_name = "bicep-win-x64.exe" if target_platform == "win-x64" else f"bicep-{target_platform}"
return download_url.format(executable_name)
if system == "Windows":
return download_url.format("bicep-win-x64.exe")
if system == "Linux":
if os.path.exists("/lib/ld-musl-x86_64.so.1") and not os.path.exists("/lib/x86_64-linux-gnu/libc.so.6"):
return download_url.format("bicep-linux-musl-x64")
return download_url.format("bicep-linux-x64")
if system == "Darwin":
return download_url.format("bicep-osx-x64")
raise ValidationError(f'The platform "{system}" is not supported.')

However, the request from urlopen(bicep_download_url) for downloading Bicep CLI is not recorded in the recording file, which has caused the CI issue mentioned above.

release_tag = release_tag if release_tag else get_bicep_latest_release_tag()
if stdout:
if release_tag:
print(f"Installing Bicep CLI {release_tag}...")
else:
print("Installing Bicep CLI...")
os.environ.setdefault("CURL_CA_BUNDLE", certifi.where())
request = urlopen(_get_bicep_download_url(system, release_tag, target_platform=target_platform))
with open(installation_path, "wb") as f:
f.write(request.read())

Additionally, I see that currently all tests related to Bicep are based on LiveScenarioTest, as in order to avoid recording binary data of bicep CLI, we should keep consistency in the bicep related tests, such as using @live_only() or LiveScenarioTest

# Because don't want to record bicep cli binary
class BicepBuildTest(LiveScenarioTest):

Copy link
Contributor

Choose a reason for hiding this comment

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

@shenglol By the way, may I ask do you have any suggestion for writing the Bicep related tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, live tests make sense as we don't want to spam the recording files with Bicep CLI binary data.

deployment_stack_model = _prepare_stacks_templates_and_parameters(
cmd, rcf, deployment_stack_model, template_file, template_spec, template_uri, parameters, query_string)

return sdk_no_wait(False, rcf.deployment_stacks.begin_create_or_update_at_subscription, name, deployment_stack_model)
Copy link
Contributor

@zhoxing-ms zhoxing-ms Jun 27, 2023

Choose a reason for hiding this comment

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

Currently, these methods do not need to support --no-wait, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's been a while since these were added but I believe these are required

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so you plan to support it in the subsequent PR in the future, right?

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, we can support it in a future PR

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jun 27, 2023

Type Test Case Error Message Line
Failed test_resource_policyexemption_default E azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception TypeError during execution and fails the command.During handling of the above exception, another exception occurred:E TypeError: 'NoneType' object is not callable azure/cli/command_modules/resource/tests/latest/test_resource.py:4358
Failed test_resource_policyexemption_management_group E azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception TypeError during execution and fails the command.During handling of the above exception, another exception occurred:E TypeError: 'NoneType' object is not callable azure/cli/command_modules/resource/tests/latest/test_resource.py:4363

The new CI issues are caused by another breaking change for PolicyExemption introduced by the new SDK package https://github.com/Azure/sdk-release-request/issues/4179#issuecomment-1609231435
@msyyc Do we need to import this model as a workaround using a fixed path from azure.mgmt.resource.policy.v2022_07_01_preview.models import PolicyExemption instead of cmd.get_models('PolicyExemption'), or is there a better solution to solve it?

@msyyc
Copy link
Member

msyyc commented Jun 27, 2023

Type Test Case Error Message Line
Failed test_resource_policyexemption_default E azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception TypeError during execution and fails the command.During handling of the above exception, another exception occurred:E TypeError: 'NoneType' object is not callable azure/cli/command_modules/resource/tests/latest/test_resource.py:4358
Failed test_resource_policyexemption_management_group E azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception TypeError during execution and fails the command.During handling of the above exception, another exception occurred:E TypeError: 'NoneType' object is not callable azure/cli/command_modules/resource/tests/latest/test_resource.py:4363
The new CI issues are caused by another breaking change for PolicyExemption introduced by the new SDK package Azure/sdk-release-request#4179 (comment) @msyyc Do we need to import this model as a workaround using a fixed path from azure.mgmt.resource.policy.v2022_07_01_preview.models import PolicyExemption instead of cmd.get_models('PolicyExemption'), or is there a better solution to solve it?

As declared here, stable api version doesn't contain this model so it can't be imported directly with default api version(default api version is stable api version.

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jun 27, 2023

@robga We found that the PolicyExemption object was defined in api-version 2022-07-01-preview of Swagger Swagger link. But it was no longer defined in subsequent api-versions of Swagger, such as 2022-06-01. Swagger link
Related PR: Azure/azure-rest-api-specs#20672

This issue resulted in some breaking changes in the generation of subsequent versions of Python SDK package, which no longer includes models such as PolicyExemption and ExemptionCategory which were previously supported in version v2020_07_01_preview. So may I ask what's the context and reasons why these models were removed in the later api-versions of Swagger?

@zhoxing-ms zhoxing-ms merged commit 58ec069 into Azure:dev Jun 28, 2023
avgale pushed a commit to avgale/azure-cli that referenced this pull request Aug 24, 2023
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.

10 participants