-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
…zure-cli into stacks_August2021
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Outdated
Show resolved
Hide resolved
From the error log of the CI pipeline pipeline link, we can see that 49 parameters were not tested, resulting in the |
@harshpatel17 Please refer to the guideline to write the description of those PR changes in the |
…ix + missed parameters added for tests
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Outdated
Show resolved
Hide resolved
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) |
There was a problem hiding this comment.
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
azure-cli/src/azure-cli/azure/cli/command_modules/resource/_bicep.py
Lines 277 to 293 in 5157cf9
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.
azure-cli/src/azure-cli/azure/cli/command_modules/resource/_bicep.py
Lines 128 to 137 in 5157cf9
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
azure-cli/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py
Lines 4046 to 4047 in 5157cf9
# Because don't want to record bicep cli binary | |
class BicepBuildTest(LiveScenarioTest): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
The new CI issues are caused by another breaking change for |
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. |
@robga We found that the This issue resulted in some breaking changes in the generation of subsequent versions of Python SDK package, which no longer includes models such as |
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
stack sub
az stack sub create
short-summary: Create a deployment stack at subscription scope
examples:
az stack sub create --name "StackName" c --template-file simpleTemplate.json --location "westus2" --description "description"
az stack sub create --name "StackName" --update-behavior "detachResources" --template-file simpleTemplate.json --parameters simpleTemplateParams.json --location "westus2" --description "description"
az stack sub create --name "StackName" --update-behavior "detachResources" --template-spec "TemplateSpecResourceIDWithVersion" --location "westus2" --description "description"
az stack sub create --name "StackName" --update-behavior "detachResources" --template-file simple.bicep --location "westus2" --description "description"
az stack sub create --name "StackName" --update-behavior "detachResources" --template-file simpleTemplate.json --location "westus2" --description "description --subscription "subscriptionId"
az stack sub create --name "StackName" --template-file simpleTemplate.json --location "westus" --resource-group "ResourceGroup" --description "description"
az stack sub create --name "StackName" --template-file simpleTemplate.json --location "westus" --description "description" --parameters simpleTemplateParams.json value1=foo value2=bar
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"
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"
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:
az stack sub list
az stack sub show
short-summary: Get specified deployment stack from subscription scope
examples:
az stack sub show --name "StackName"
az stack sub show --id "StackResourceID"
az stack sub delete
short-summary: Delete specified deployment stack from subscription scope
examples:
az stack sub delete --name "StackName"
az stack sub delete --id "StackResourceID"
az stack sub export
short-summary: Exports the template used to create the deployment stack
examples:
az stack sub export --name "StackName"
az stack sub export --id "StackResourceID"
stacks group
az stack group create
short-summary: Create a deployment stack at resource group scope
examples:
az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simpleTemplate.json --description "description"
az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simpleTemplate.json --parameters simpleTemplateParams.json --description "description"
az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-spec "TemplateSpecResourceIDWithVersion" --description "description"
az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simple.bicep --description "description"
az stack group create --name "StackName" --resource-group "ResourceGroup" --update-behavior "detachResources" --template-file simpleTemplate.json --description "description --subscription "subscriptionId"
az stack group create --name "StackName" --template-file simpleTemplate.json --resource-group "ResourceGroup" --description "description" --parameters simpleTemplateParams.json value1=foo value2=bar
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"
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"
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:
az stack group list --resource-group "ResourceGroup"
az stack group show
short-summary: Get specified deployment stack from resource group scope
examples:
az stack group show --name "StackName" --resource-group "ResourceGroup"
az stack group show --id "StackResourceID"
az stack group delete
short-summary: Delete specified deployment stack from resource group scope
examples:
az stack group delete --name "StackName" --resource-group "ResourceGroup"
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:
az stack group export --name "StackName" --resource-group "ResourceGroup"
az stack group export --id "StackResourceID"
stacks mg
az stack mg create
short-summary: Create a deployment stack at management group scope
examples:
az stack mg create --name "StackName" --management-group-id myMg --template-file simpleTemplate.json --location "westus2" --description "description"
az stack mg create --name "StackName" --management-group-id myMg --update-behavior "detachResources" --template-file simpleTemplate.json --parameters simpleTemplateParams.json --location "westus2" --description "description"
az stack mg create --name "StackName" --management-group-id myMg --update-behavior "detachResources" --template-spec "TemplateSpecResourceIDWithVersion" --location "westus2" --description "description"
az stack mg create --name "StackName" --management-group-id myMg --update-behavior "detachResources" --template-file simple.bicep --location "westus2" --description "description"
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
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"
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"
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:
az stack mg list ----management-group-id myMg
az stack mg show
short-summary: Get specified deployment stack from management group scope
examples:
az stack mg show --name "StackName" --management-group-id myMg
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:
az stack mg delete --name "StackName" --management-group-id myMg
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:
az stack mg export --name "StackName" --management-group-id myMg
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 scopeThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.