-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Container app] az containerapp env create: Add parameter --infrastructure-resource-group to support specifying name for resource group that will contain infrastructure resources
#32457
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
Open
Greedygre
wants to merge
2
commits into
dev
Choose a base branch
from
xinyu/20251125_move_infrastructure_resource_group
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,550
−1
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
66 changes: 66 additions & 0 deletions
66
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/custom_preparers.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import time | ||
|
|
||
| from azure.cli.command_modules.containerapp._utils import format_location | ||
|
|
||
| from azure.cli.testsdk import CliTestError | ||
| from azure.cli.testsdk.reverse_dependency import get_dummy_cli | ||
| from azure.cli.testsdk.scenario_tests import SingleValueReplacer | ||
| from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer, ResourceGroupPreparer | ||
| from .common import STAGE_LOCATION | ||
|
|
||
| class SubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): | ||
| def __init__(self, name_prefix='vnet', location="centralus", location_replace_stage="centralus", resource_group_parameter_name='resource_group', vnet_name=None, vnet_address_prefixes='14.0.0.0/23', subnet_address_prefixes='14.0.0.0/23', | ||
| delegations=None, subnet_name="default", service_endpoints=None, skip_delete=False): | ||
| super(SubnetPreparer, self).__init__(name_prefix, 15) | ||
| self.cli_ctx = get_dummy_cli() | ||
| self.location = location | ||
| self.resource_group_parameter_name = resource_group_parameter_name | ||
| self.vnet_name = vnet_name | ||
| if vnet_name is None: | ||
| self.vnet_name = self.create_random_name() | ||
| self.vnet_address_prefixes = vnet_address_prefixes | ||
| self.subnet_address_prefixes = subnet_address_prefixes | ||
| self.delegations = delegations | ||
| self.subnet_name = subnet_name | ||
| self.service_endpoints = service_endpoints | ||
| self.skip_delete = skip_delete | ||
| self.location_replace_stage = location_replace_stage | ||
|
|
||
| def create_resource(self, name, **kwargs): | ||
| resource_group = self._get_resource_group(**kwargs) | ||
| subnet_id = "FAKESUBNETID" | ||
| location = self.location | ||
| if format_location(location) == format_location(STAGE_LOCATION): | ||
| location = self.location_replace_stage | ||
|
|
||
| # try: | ||
| self.live_only_execute(self.cli_ctx, f"az network vnet create --address-prefixes {self.vnet_address_prefixes} -g {resource_group} -n {self.vnet_name} --subnet-name {self.subnet_name} --location {location}") | ||
| subnet_command = f"az network vnet subnet update --address-prefixes {self.subnet_address_prefixes} " \ | ||
| f"-n {self.subnet_name} " \ | ||
| f"-g {resource_group} " \ | ||
| f"--vnet-name {self.vnet_name} " | ||
| if self.service_endpoints is not None: | ||
| subnet_command += f'--service-endpoints {self.service_endpoints} ' | ||
|
|
||
| if self.delegations is not None: | ||
| subnet_command += f'--delegations {self.delegations} ' | ||
|
|
||
| subnet_id = self.live_only_execute(self.cli_ctx, subnet_command).get_output_in_json()["id"] | ||
| # except AttributeError: # live only execute returns None if playing from record | ||
| # pass | ||
| return {'subnet_id': subnet_id, | ||
| 'vnet_name': self.vnet_name, | ||
| 'subnet_name': self.subnet_name} | ||
|
|
||
| def _get_resource_group(self, **kwargs): | ||
| try: | ||
| return kwargs.get(self.resource_group_parameter_name) | ||
| except KeyError: | ||
| template = 'Resource group is required. Please add ' \ | ||
| 'decorator @{} in front of this preparer.' | ||
| raise CliTestError(template.format(ResourceGroupPreparer.__name__, | ||
| self.resource_group_parameter_name)) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.