diff --git a/src/containerapp/HISTORY.rst b/src/containerapp/HISTORY.rst index 502f10714f8..abdf72c99c9 100644 --- a/src/containerapp/HISTORY.rst +++ b/src/containerapp/HISTORY.rst @@ -5,7 +5,7 @@ Release History 0.3.10 ++++++ - +* 'az containerapp create': Fix bug with --image caused by assuming a value for --registry-server 0.3.9 ++++++ diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index d91e238684c..563c8ac488c 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -329,8 +329,6 @@ def create_containerapp(cmd, disable_warnings=False, user_assigned=None, registry_identity=None): - if image and "/" in image and not registry_server: - registry_server = image[:image.index("/")] register_provider_if_needed(cmd, CONTAINER_APPS_RP) validate_container_app_name(name) validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait) diff --git a/src/containerapp/azext_containerapp/tests/latest/test_containerapp_commands.py b/src/containerapp/azext_containerapp/tests/latest/test_containerapp_commands.py index 664f7e50ec9..40a01b14404 100644 --- a/src/containerapp/azext_containerapp/tests/latest/test_containerapp_commands.py +++ b/src/containerapp/azext_containerapp/tests/latest/test_containerapp_commands.py @@ -561,6 +561,34 @@ def test_containerapp_revision_label_e2e(self, resource_group): self.assertEqual(len([w for w in traffic_weight if "label" in w]), 0) +class ContainerappAnonymousRegistryTests(ScenarioTest): + @AllowLargeResponse(8192) + @ResourceGroupPreparer(location="northeurope") + @live_only() # encounters 'CannotOverwriteExistingCassetteException' only when run from recording (passes when run live) + def test_containerapp_anonymous_registry(self, resource_group): + import requests + + env = self.create_random_name(prefix='env', length=24) + app = self.create_random_name(prefix='aca', length=24) + image = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest" + + self.cmd(f'containerapp env create -g {resource_group} -n {env}') + + containerapp_env = self.cmd(f'containerapp env show -g {resource_group} -n {env}').get_output_in_json() + + while containerapp_env["properties"]["provisioningState"].lower() == "waiting": + time.sleep(5) + containerapp_env = self.cmd(f'containerapp env show -g {resource_group} -n {env}').get_output_in_json() + + self.cmd(f'containerapp create -g {resource_group} -n {app} --image {image} --ingress external --target-port 80 --environment {env}') + + url = self.cmd(f'containerapp show -g {resource_group} -n {app}').get_output_in_json()["properties"]["configuration"]["ingress"]["fqdn"] + url = f"https://{url}" + resp = requests.get(url) + self.assertTrue(resp.ok) + self.assertEqual(resp.status_code, 200) + + class ContainerappRegistryIdentityTests(ScenarioTest): @AllowLargeResponse(8192) @ResourceGroupPreparer(location="westeurope")