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
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Upcoming
* 'az containerapp create/update': --yaml support properties for api-version 2023-04-01-preview (e.g. subPath, mountOptions)
* 'az containerapp service': add support for creation and deletion of kafka
* 'az containerapp create': --registry-server support registry with custom port
* 'az containerapp create': fix containerapp create not waiting for ready environment
* Add regex to fix validation for containerapp name

0.3.33
Expand Down
5 changes: 5 additions & 0 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ def create_containerapp(cmd,
if not managed_env_info:
raise ValidationError("The environment '{}' does not exist. Specify a valid environment".format(managed_env))

while not no_wait and safe_get(managed_env_info, "properties", "provisioningState", default="").lower() in ["inprogress", "updating"]:
logger.info("Waiting for environment provisioning to finish before creating container app")
time.sleep(5)
managed_env_info = ManagedEnvironmentClient.show(cmd=cmd, resource_group_name=managed_env_rg, name=managed_env_name)

location = managed_env_info["location"]
_ensure_location_allowed(cmd, location, CONTAINER_APPS_RP, "containerApps")

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 @@ -244,6 +244,68 @@ def test_containerapp_create_with_workloadprofile_yaml(self, resource_group):
clean_up_test_file(containerapp_file_name_01)
clean_up_test_file(containerapp_file_name_02)

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location="eastus")
def test_containerapp_env_workload_profiles_e2e_no_waits(self, resource_group):
import requests

env = self.create_random_name(prefix='env', length=24)
vnet = self.create_random_name(prefix='name', length=24)
app1 = self.create_random_name(prefix='app1', length=24)
app2 = self.create_random_name(prefix='app2', length=24)

location = "eastus"

self.cmd('containerapp env create -g {} -n {} --location {} --logs-destination none --enable-workload-profiles'.format(resource_group, env, location))

containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env)).get_output_in_json()

while containerapp_env["properties"]["provisioningState"].lower() in ["waiting", "inprogress"]:
time.sleep(5)
containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env)).get_output_in_json()
time.sleep(30)

self.cmd('containerapp env show -n {} -g {}'.format(env, resource_group), checks=[
JMESPathCheck('name', env),
JMESPathCheck('properties.workloadProfiles[0].name', "Consumption", case_sensitive=False),
JMESPathCheck('properties.workloadProfiles[0].workloadProfileType', "Consumption", case_sensitive=False),
])

self.cmd("az containerapp env workload-profile list-supported -l {}".format(location))

profiles = self.cmd("az containerapp env workload-profile list -g {} -n {}".format(resource_group, env)).get_output_in_json()
self.assertEqual(len(profiles), 1)
self.assertEqual(profiles[0]["properties"]["name"].lower(), "consumption")
self.assertEqual(profiles[0]["properties"]["workloadProfileType"].lower(), "consumption")

self.cmd("az containerapp env workload-profile add -g {} -n {} --workload-profile-name my-d4 --workload-profile-type D4 --min-nodes 2 --max-nodes 3".format(resource_group, env))

self.cmd("az containerapp create -g {} --target-port 80 --ingress external --image mcr.microsoft.com/k8se/quickstart:latest --revision-suffix suf1 --environment {} -n {} --workload-profile-name my-d4 --cpu 0.5 --memory 1Gi".format(resource_group, env, app1))

containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env)).get_output_in_json()

self.cmd(f'containerapp show -g {resource_group} -n {app1}', checks=[
JMESPathCheck("properties.provisioningState", "Succeeded"),
JMESPathCheck("properties.template.revisionSuffix", "suf1"),
JMESPathCheck("properties.workloadProfileName", "my-d4"),
JMESPathCheck("properties.template.containers[0].resources.cpu", "0.5"),
JMESPathCheck("properties.template.containers[0].resources.memory", "1Gi")
])

self.cmd("az containerapp env workload-profile update -g {} -n {} --workload-profile-name my-d4 --min-nodes 1 --max-nodes 2".format(resource_group, env))

self.cmd("az containerapp create -g {} --target-port 80 --ingress external --image mcr.microsoft.com/k8se/quickstart:latest --revision-suffix suf2 --environment {} -n {} --workload-profile-name my-d4 --cpu 0.5 --memory 1Gi".format(resource_group, env, app2))

containerapp_env = self.cmd('containerapp env show -g {} -n {}'.format(resource_group, env)).get_output_in_json()

self.cmd(f'containerapp show -g {resource_group} -n {app2}', checks=[
JMESPathCheck("properties.provisioningState", "Succeeded"),
JMESPathCheck("properties.template.revisionSuffix", "suf2"),
JMESPathCheck("properties.workloadProfileName", "my-d4"),
JMESPathCheck("properties.template.containers[0].resources.cpu", "0.5"),
JMESPathCheck("properties.template.containers[0].resources.memory", "1Gi")
])

def assertContainerappProperties(self, containerapp_env, rg, app, workload_profile_name, revision, cpu, mem):
self.cmd(f'containerapp show -g {rg} -n {app}', checks=[
JMESPathCheck("properties.provisioningState", "Succeeded"),
Expand Down