Skip to content

Commit 1660890

Browse files
[Containerapp] az containerapp create: Support --kind {functionapp} (#8472)
1 parent e9f25f4 commit 1660890

File tree

8 files changed

+3639
-2
lines changed

8 files changed

+3639
-2
lines changed

src/containerapp/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Release History
44
===============
55
upcoming
66
++++++
7+
* 'az containerapp create': support --kind {functionapp}
78

89
1.1.0b3
910
++++++

src/containerapp/azext_containerapp/_help.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,11 @@
908908
az containerapp create -n my-containerapp -g MyResourceGroup \\
909909
--image my-app:v1.0 --environment MyContainerappEnv \\
910910
--enable-java-agent
911+
- name: Create a container app with kind as functionapp
912+
text: |
913+
az containerapp create -n my-containerapp -g MyResourceGroup \\
914+
--image my-app:v1.0 --environment MyContainerappEnv \\
915+
--kind functionapp
911916
"""
912917

913918
# containerapp update for preview

src/containerapp/azext_containerapp/_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@
278278
"template": None, # Template
279279
"workloadProfileName": None
280280
},
281-
"tags": None
281+
"tags": None,
282+
"kind": None
282283
}
283284

284285
ContainerAppsJob = {

src/containerapp/azext_containerapp/_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def load_arguments(self, _):
3636
c.argument('build_env_vars', nargs='*', help="A list of environment variable(s) for the build. Space-separated values in 'key=value' format.",
3737
validator=validate_build_env_vars, is_preview=True)
3838
c.argument('max_inactive_revisions', type=int, help="Max inactive revisions a Container App can have.", is_preview=True)
39+
c.argument('kind', type=str, help="Set to 'functionapp' to get built in support and autoscaling to run Azure functions on Azure Container apps", is_preview=True)
3940
c.argument('registry_identity', help="The managed identity with which to authenticate to the Azure Container Registry (instead of username/password). Use 'system' for a system-defined identity, Use 'system-environment' for an environment level system-defined identity or a resource id for a user-defined environment/containerapp level identity. The managed identity should have been assigned acrpull permissions on the ACR before deployment (use 'az role assignment create --role acrpull ...').")
4041
c.argument('target_label', help="The label to apply to new revisions. Required for revisions-mode 'labels'.", is_preview=True)
4142

src/containerapp/azext_containerapp/containerapp_decorator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ def get_argument_customized_keys(self):
659659
def get_argument_service_connectors_def_list(self):
660660
return self.get_param("service_connectors_def_list")
661661

662+
def get_argument_kind(self):
663+
return self.get_param("kind")
664+
662665
def set_argument_service_connectors_def_list(self, service_connectors_def_list):
663666
self.set_param("service_connectors_def_list", service_connectors_def_list)
664667

@@ -906,6 +909,8 @@ def construct_payload(self):
906909
self.set_up_repo()
907910
if self.get_argument_max_inactive_revisions() is not None:
908911
safe_set(self.containerapp_def, "properties", "configuration", "maxInactiveRevisions", value=self.get_argument_max_inactive_revisions())
912+
if self.get_argument_kind() is not None:
913+
safe_set(self.containerapp_def, "kind", value=self.get_argument_kind())
909914
self.set_up_runtime()
910915

911916
# copy from parent

src/containerapp/azext_containerapp/custom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ def create_containerapp(cmd,
506506
max_inactive_revisions=None,
507507
runtime=None,
508508
enable_java_metrics=None,
509-
enable_java_agent=None):
509+
enable_java_agent=None,
510+
kind=None):
510511
raw_parameters = locals()
511512

512513
containerapp_create_decorator = ContainerAppPreviewCreateDecorator(

src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_kind_functionapp.yaml

Lines changed: 3599 additions & 0 deletions
Large diffs are not rendered by default.

src/containerapp/azext_containerapp/tests/latest/test_containerapp_commands.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,6 +3361,30 @@ def test_containerapp_max_inactive_revisions(self, resource_group):
33613361
self.cmd(f'containerapp update -g {resource_group} -n {app} --cpu 0.25 --memory 0.5Gi')
33623362
self.cmd(f'containerapp show -g {resource_group} -n {app}', checks=[JMESPathCheck("properties.configuration.maxInactiveRevisions", maxInactiveRevisions)])
33633363

3364+
@AllowLargeResponse(8192)
3365+
@ResourceGroupPreparer(location="centraluseuap")
3366+
def test_containerapp_kind_functionapp(self, resource_group):
3367+
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
3368+
3369+
app = self.create_random_name(prefix='aca', length=24)
3370+
image = "mcr.microsoft.com/k8se/quickstart:latest"
3371+
3372+
env = prepare_containerapp_env_for_app_e2e_tests(self)
3373+
3374+
self.cmd(f'containerapp create -g {resource_group} -n {app} --image {image} --ingress external --target-port 80 --environment {env} --cpu 0.5 --memory 1Gi', checks=[
3375+
JMESPathCheck("properties.provisioningState", "Succeeded"),
3376+
JMESPathCheck("kind", None)
3377+
])
3378+
3379+
self.cmd(f'containerapp create -g {resource_group} -n {app} --image {image} --ingress external --target-port 80 --environment {env} --kind functionapp', checks=[
3380+
JMESPathCheck("properties.provisioningState", "Succeeded"),
3381+
JMESPathCheck("kind", "functionapp")
3382+
])
3383+
3384+
self.cmd(f'containerapp update -g {resource_group} -n {app} --cpu 0.25 --memory 0.5Gi', checks=[
3385+
JMESPathCheck("properties.provisioningState", "Succeeded"),
3386+
JMESPathCheck("kind", "functionapp")
3387+
])
33643388

33653389
class ContainerappRuntimeTests(ScenarioTest):
33663390
def __init__(self, *arg, **kwargs):

0 commit comments

Comments
 (0)