Skip to content
Merged
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release History
upcoming
++++++
* 'az containerapp create': Fix Role assignment error when the default Azure Container Registry could not be found
* Upgrade api-version to 2024-10-02-preview

1.0.0b4
++++++
Expand Down
23 changes: 18 additions & 5 deletions src/containerapp/azext_containerapp/_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

logger = get_logger(__name__)

PREVIEW_API_VERSION = "2024-02-02-preview"
AUG_PREVIEW_API_VERSION = "2024-08-02-preview"
PREVIEW_API_VERSION = "2024-10-02-preview"
POLLING_TIMEOUT = 1500 # how many seconds before exiting
POLLING_SECONDS = 2 # how many seconds between requests
POLLING_TIMEOUT_FOR_MANAGED_CERTIFICATE = 1500 # how many seconds before exiting
Expand Down Expand Up @@ -552,7 +551,7 @@ def list_certificates(cls, cmd, resource_group_name, name, formatter=lambda x: x
return certs_list

@classmethod
def create_or_update_certificate(cls, cmd, resource_group_name, name, certificate_name, certificate):
def create_or_update_certificate(cls, cmd, resource_group_name, name, certificate_name, certificate, no_wait=False):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/connectedEnvironments/{}/certificates/{}?api-version={}"
Expand All @@ -565,6 +564,13 @@ def create_or_update_certificate(cls, cmd, resource_group_name, name, certificat
cls.api_version)

r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(certificate))
if no_wait:
return r.json()
elif r.status_code == 201:
operation_url = r.headers.get(HEADER_AZURE_ASYNC_OPERATION)
poll_status(cmd, operation_url)
r = send_raw_request(cmd.cli_ctx, "GET", request_url)

return r.json()

@classmethod
Expand Down Expand Up @@ -603,7 +609,7 @@ class ConnectedEnvDaprComponentClient():
api_version = PREVIEW_API_VERSION

@classmethod
def create_or_update(cls, cmd, resource_group_name, environment_name, name, dapr_component_envelope):
def create_or_update(cls, cmd, resource_group_name, environment_name, name, dapr_component_envelope, no_wait=False):

management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
Expand All @@ -618,6 +624,13 @@ def create_or_update(cls, cmd, resource_group_name, environment_name, name, dapr

r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(dapr_component_envelope))

if no_wait:
return r.json()
elif r.status_code == 201:
operation_url = r.headers.get(HEADER_AZURE_ASYNC_OPERATION)
poll_status(cmd, operation_url)
r = send_raw_request(cmd.cli_ctx, "GET", request_url)

return r.json()

@classmethod
Expand Down Expand Up @@ -887,7 +900,7 @@ def list_auth_token(cls, cmd, builder_name, build_name, resource_group_name, loc


class JavaComponentPreviewClient():
api_version = AUG_PREVIEW_API_VERSION
api_version = PREVIEW_API_VERSION
Comment thread
Greedygre marked this conversation as resolved.

@classmethod
def create(cls, cmd, resource_group_name, environment_name, name, java_component_envelope, no_wait=False):
Expand Down
32 changes: 32 additions & 0 deletions src/containerapp/azext_containerapp/_decorator_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# pylint: disable=line-too-long, consider-using-f-string, no-else-return, duplicate-string-formatting-argument, expression-not-assigned, too-many-locals, logging-fstring-interpolation, broad-except, pointless-statement, bare-except
import sys

from azure.cli.command_modules.containerapp._utils import _to_camel_case
from azure.cli.core.azclierror import (ValidationError)

from ._constants import RUNTIME_JAVA
Expand Down Expand Up @@ -81,6 +82,24 @@ def process_loaded_yaml(yaml_containerapp):
return yaml_containerapp


def process_loaded_yaml_for_connected_env_dapr(yaml_dapr_component):
from ._sdk_models import ConnectedEnvironmentDaprComponentProperties

if not isinstance(yaml_dapr_component, dict): # pylint: disable=unidiomatic-typecheck
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')
if not yaml_dapr_component.get('properties'):
yaml_dapr_component['properties'] = {}
# Get the value of all "key" in _attribute_map
nested_properties = [key["key"] for key in ConnectedEnvironmentDaprComponentProperties._attribute_map.values()]
for nested_property in nested_properties:
Comment thread
Greedygre marked this conversation as resolved.
Outdated
tmp = yaml_dapr_component.get(nested_property)
if nested_property in yaml_dapr_component:
yaml_dapr_component['properties'][nested_property] = tmp
del yaml_dapr_component[nested_property]

return yaml_dapr_component


def process_containerapp_resiliency_yaml(containerapp_resiliency):

if not isinstance(containerapp_resiliency, dict): # pylint: disable=unidiomatic-typecheck
Expand Down Expand Up @@ -134,3 +153,16 @@ def infer_runtime_option(runtime, enable_java_metrics, enable_java_agent):
if enable_java_agent is not None:
return RUNTIME_JAVA
return None


def _remove_readonly_attributes_with_class_name(definition, module_path, class_name):
from importlib import import_module
module = import_module(module_path)
class_def = getattr(module, class_name, None)
unneeded_properties = [_to_camel_case(key) for key, value in class_def._validation.items() if value.get("readonly")]

for unneeded_property in unneeded_properties:
if unneeded_property in definition:
del definition[unneeded_property]
elif unneeded_property in definition['properties']:
del definition['properties'][unneeded_property]
77 changes: 74 additions & 3 deletions src/containerapp/azext_containerapp/_sdk_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ class ActiveRevisionsMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):

.. raw:: html

<list><item>Multiple: multiple revisions can be active.</item><item>Single: Only one
revision can be active at a time. Revision weights can not be used in this mode. If no value if
provided, this is the default.</item></list>.
<list><item>Single: Only one revision can be active at a time. Traffic weights cannot be
used. This is the default.</item><item>Multiple: Multiple revisions can be active, including
optional traffic weights and labels.</item><item>Labels: Only revisions with labels are active.
Traffic weights can be applied to labels.</item></list>.
"""

MULTIPLE = "Multiple"
SINGLE = "Single"
LABELS = "Labels"


class Affinity(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down Expand Up @@ -69,6 +71,7 @@ class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta):

DISABLED = "Disabled"
SNI_ENABLED = "SniEnabled"
AUTO = "Auto"


class BuilderProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down Expand Up @@ -129,6 +132,15 @@ class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta):
ALREADY_EXISTS = "AlreadyExists"


class ConnectedEnvironmentDaprComponentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the Connected Environment Dapr Component."""

SUCCEEDED = "Succeeded"
FAILED = "Failed"
CANCELED = "Canceled"
IN_PROGRESS = "InProgress"


class ConnectedEnvironmentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the Kubernetes Environment."""

Expand All @@ -142,6 +154,15 @@ class ConnectedEnvironmentProvisioningState(str, Enum, metaclass=CaseInsensitive
SCHEDULED_FOR_DELETE = "ScheduledForDelete"


class ConnectedEnvironmentStorageProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the storage."""

SUCCEEDED = "Succeeded"
FAILED = "Failed"
CANCELED = "Canceled"
IN_PROGRESS = "InProgress"


class ContainerAppContainerRunningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Current running state of the container."""

Expand All @@ -168,6 +189,21 @@ class ContainerAppReplicaRunningState(str, Enum, metaclass=CaseInsensitiveEnumMe
UNKNOWN = "Unknown"


class ContainerAppRunningStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Running status of the Container App."""

PROGRESSING = "Progressing"
"""Container App is transitioning between Stopped and Running states."""
RUNNING = "Running"
"""Container App is in Running state."""
STOPPED = "Stopped"
"""Container App is in Stopped state."""
SUSPENDED = "Suspended"
"""Container App Job is in Suspended state."""
READY = "Ready"
"""Container App Job is in Ready state."""


class ContainerType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The container type of the sessions."""

Expand Down Expand Up @@ -258,6 +294,18 @@ class ForwardProxyConvention(str, Enum, metaclass=CaseInsensitiveEnumMeta):
CUSTOM = "Custom"


class HttpRouteProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The current provisioning state."""

SUCCEEDED = "Succeeded"
FAILED = "Failed"
CANCELED = "Canceled"
WAITING = "Waiting"
UPDATING = "Updating"
DELETING = "Deleting"
PENDING = "Pending"


class IdentitySettingsLifeCycle(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Use to select the lifecycle stages of a Container App during which the Managed Identity should
be available.
Expand Down Expand Up @@ -321,6 +369,7 @@ class JavaComponentType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
SPRING_BOOT_ADMIN = "SpringBootAdmin"
SPRING_CLOUD_EUREKA = "SpringCloudEureka"
SPRING_CLOUD_CONFIG = "SpringCloudConfig"
SPRING_CLOUD_GATEWAY = "SpringCloudGateway"
NACOS = "Nacos"


Expand All @@ -346,6 +395,14 @@ class JobProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
DELETING = "Deleting"


class JobRunningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Current running state of the job."""

READY = "Ready"
PROGRESSING = "Progressing"
SUSPENDED = "Suspended"


class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Metadata used to render different experiences for resources of the same type; e.g. WorkflowApp
is a kind of Microsoft.App/ContainerApps type. If supported, the resource provider must
Expand Down Expand Up @@ -535,6 +592,20 @@ class UnauthenticatedClientActionV2(str, Enum, metaclass=CaseInsensitiveEnumMeta
RETURN403 = "Return403"


class WeekDay(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Day of the week when a managed environment can be patched."""

MONDAY = "Monday"
TUESDAY = "Tuesday"
WEDNESDAY = "Wednesday"
THURSDAY = "Thursday"
FRIDAY = "Friday"
SATURDAY = "Saturday"
SUNDAY = "Sunday"
EVERYDAY = "Everyday"
WEEKEND = "Weekend"


class WorkflowHealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Gets or sets the workflow health state."""

Expand Down
Loading