Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,15 @@ def set_up_infrastructure_resource_group(self):
self.managed_env_def["properties"]["InfrastructureResourceGroup"] = self.get_argument_infrastructure_resource_group()

def set_up_workload_profiles(self):
# If the environment exists, infer the environment type
existing_environment = None
try:
existing_environment = self.client.show(cmd=self.cmd,
resource_group_name=self.get_argument_resource_group_name(),
name=self.get_argument_name())
except Exception as e:
handle_non_404_status_code_exception(e)
if self.get_argument_enable_workload_profiles():
# If the environment exists, infer the environment type
existing_environment = None
try:
existing_environment = self.client.show(cmd=self.cmd,
resource_group_name=self.get_argument_resource_group_name(),
name=self.get_argument_name())
except Exception as e:
handle_non_404_status_code_exception(e)

if existing_environment and safe_get(existing_environment, "properties", "workloadProfiles") is None:
# check if input params include -w/--enable-workload-profiles
if self.cmd.cli_ctx.data.get('safe_params') and ('-w' in self.cmd.cli_ctx.data.get(
Expand All @@ -244,6 +243,10 @@ def set_up_workload_profiles(self):
return

self.managed_env_def["properties"]["workloadProfiles"] = get_default_workload_profiles(self.cmd, self.get_argument_location())
else:
if existing_environment and safe_get(existing_environment, "properties", "workloadProfiles") is not None:
raise ValidationError(
f"Existing environment {self.get_argument_name()} uses workload profiles. If you want to use Consumption-Only environment, please create a new one.")

def set_up_app_log_configuration(self):
if (self.get_argument_logs_customer_id() is None or self.get_argument_logs_key() is None) and self.get_argument_logs_destination() == "log-analytics":
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 @@ -13,7 +13,7 @@
clean_up_test_file,
TEST_DIR, TEST_LOCATION)

from .utils import create_containerapp_env, prepare_containerapp_env_for_app_e2e_tests
from .utils import prepare_containerapp_env_for_app_e2e_tests


# flake8: noqa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
clean_up_test_file,
TEST_DIR, TEST_LOCATION)

from .utils import create_containerapp_env, prepare_containerapp_env_for_app_e2e_tests
from .utils import prepare_containerapp_env_for_app_e2e_tests


# flake8: noqa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
write_test_file,
clean_up_test_file,
TEST_DIR, TEST_LOCATION)
from .utils import create_containerapp_env, prepare_containerapp_env_for_app_e2e_tests
from .utils import prepare_containerapp_env_for_app_e2e_tests


# flake8: noqa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
import yaml

from azure.cli.core.azclierror import ValidationError
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, live_only, StorageAccountPreparer,
LogAnalyticsWorkspacePreparer)
Expand Down Expand Up @@ -51,6 +52,11 @@ def test_containerapp_env_e2e(self, resource_group, laworkspace_customer_id, law
JMESPathCheck('name', env_name),
])

# before deleting, validate can't create a consumption only environment
with self.assertRaisesRegex(ValidationError,
f"Existing environment {env_name} uses workload profiles. If you want to use Consumption-Only environment, please create a new one."):
self.cmd('containerapp env create -g {} -n {} --logs-workspace-id {} --logs-workspace-key {} --tags "foo=bar" "key1=val1" --enable-workload-profiles false'.format(resource_group, env_name, laworkspace_customer_id, laworkspace_shared_key))

self.cmd('containerapp env delete -g {} -n {} --yes'.format(resource_group, env_name))

self.cmd('containerapp env list -g {}'.format(resource_group), checks=[
Expand Down