Skip to content

Commit

Permalink
[Container app] az containerapp up: Fix issue for auto-creating res…
Browse files Browse the repository at this point in the history
…ource group (Azure#7601)
  • Loading branch information
Greedygre authored May 13, 2024
1 parent 1b29373 commit 7dcaa84
Show file tree
Hide file tree
Showing 7 changed files with 17,178 additions and 10,596 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ upcoming
* 'az containerapp create/update': Support enable or disable Java metrics with --runtime and --enable-java-metrics
* 'az containerapp update': Fix --scale-rule-tcp-concurrency for TCP scale rule
* 'az containerapp compose create': Fix an issue where the environment's location is not resolved from --location
* 'az containerapp up': Fix an issue about creating resource group automatically

0.3.50
++++++
Expand Down
14 changes: 12 additions & 2 deletions src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ValidationError,
InvalidArgumentValueError,
MutuallyExclusiveArgumentError,
CLIError,
CLIError, CLIInternalError,
)
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.command_modules.appservice._create_util import (
Expand Down Expand Up @@ -1405,7 +1405,17 @@ def _infer_existing_connected_env(
custom_location: "CustomLocation",
):
if not env.resource_type or (env.is_connected_environment() and (not env.name or not resource_group.name or not env.custom_location_id)):
connected_env_list = list_connected_environments(cmd=cmd, resource_group_name=resource_group.name)
connected_env_list = []
try:
connected_env_list = list_connected_environments(cmd=cmd, resource_group_name=resource_group.name)
except CLIInternalError as e:
string_err = str(e)
# If a resource group is provided but not found, we will automatically create it in a subsequent step
if "ResourceGroupNotFound" in string_err:
pass
else:
raise e

env_list = []
for e in connected_env_list:
if env.name and env.name != e["name"]:
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,35 @@
import os
import unittest

from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, live_only)
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, live_only, JMESPathCheck)

from azext_containerapp.tests.latest.utils import create_and_verify_containerapp_up, create_and_verify_containerapp_up_with_multiple_environments, create_and_verify_containerapp_up_for_default_registry_image
from .utils import (create_and_verify_containerapp_up,
create_and_verify_containerapp_up_with_multiple_environments,
create_and_verify_containerapp_up_for_default_registry_image,
prepare_containerapp_env_for_app_e2e_tests)

TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))


class ContainerAppUpImageTest(ScenarioTest):

def test_containerapp_up_create_resource_group(self):
resource_group = self.create_random_name(prefix='cli.group', length=24)
image = "mcr.microsoft.com/k8se/quickstart:latest"
ca_name = self.create_random_name(prefix='containerapp', length=24)

env = prepare_containerapp_env_for_app_e2e_tests(self)

self.cmd(
'containerapp up -g {} -n {} --image {} --environment {} --ingress external --target-port 80'.format(
resource_group, ca_name, image, env), expect_failure=False)

self.cmd(f'containerapp show -g {resource_group} -n {ca_name}', checks=[
JMESPathCheck("resourceGroup", resource_group),
JMESPathCheck("properties.provisioningState", "Succeeded"),
])
self.cmd(f'group delete -n {resource_group} --yes --no-wait', expect_failure=False)

@live_only()
@ResourceGroupPreparer(location="eastus2")
def test_containerapp_up_image_e2e(self, resource_group):
Expand Down

0 comments on commit 7dcaa84

Please sign in to comment.