Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
207428e
app/revision level replica count
Juancpani Sep 11, 2023
5ceff5b
added help text
Juancpani Sep 13, 2023
773d1cb
help changes
Juancpani Sep 13, 2023
b8ef608
comment fixes: exception handling
Juancpani Sep 13, 2023
82076e3
added latestRevisionName validation
Juancpani Sep 13, 2023
469d46b
static fix
Juancpani Sep 13, 2023
b1f221d
replica count history
Juancpani Sep 13, 2023
0fad2b1
static fix
Juancpani Sep 13, 2023
fb80de8
Merge branch 'main' into replica-count
Juancpani Sep 13, 2023
b194605
added preview flag
Juancpani Sep 18, 2023
2224224
app/revision level replica count
Juancpani Sep 11, 2023
f0b794e
added help text
Juancpani Sep 13, 2023
faca0c5
help changes
Juancpani Sep 13, 2023
ee90d30
comment fixes: exception handling
Juancpani Sep 13, 2023
c0e474c
added latestRevisionName validation
Juancpani Sep 13, 2023
feede44
static fix
Juancpani Sep 13, 2023
ff5b0c0
replica count history
Juancpani Sep 13, 2023
77258aa
static fix
Juancpani Sep 13, 2023
adcba8b
added preview flag
Juancpani Sep 18, 2023
f50191c
added testing and extra validation
Juancpani Oct 3, 2023
b838fc8
test recordings
Juancpani Oct 3, 2023
805a413
Merge branch 'replica-count' of https://github.com/Juancpani/azure-cl…
Juancpani Oct 3, 2023
499ec2b
app/revision level replica count
Juancpani Sep 11, 2023
4b18e47
added help text
Juancpani Sep 13, 2023
350aed8
comment fixes: exception handling
Juancpani Sep 13, 2023
fb67873
added latestRevisionName validation
Juancpani Sep 13, 2023
a2274ac
static fix
Juancpani Sep 13, 2023
27adba1
static fix
Juancpani Sep 13, 2023
41088fb
Merge branch 'replica-count' of https://github.com/Juancpani/azure-cl…
Juancpani Oct 3, 2023
2dd2b25
static analysis fix
Juancpani Oct 3, 2023
c7dd991
remove duplicate function
Juancpani Oct 3, 2023
85076f4
Update src/containerapp/HISTORY.rst
Juancpani Oct 6, 2023
6170cfc
Merge branch 'main' into replica-count
Juancpani Oct 9, 2023
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 projects

@zhoxing-ms zhoxing-ms Dec 5, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, I would like to confirm why the projects folder was added at that time? @Juancpani @Greedygre

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Juancpani
Is this projects folder added by mistake?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the projects folder addition was a mistake. We should remove it.

Submodule projects added at 650f20
2 changes: 2 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Release History
===============
upcoming
++++++
* 'az containerapp replica count', returns the replica count of a container app
Comment thread
Juancpani marked this conversation as resolved.

0.3.41
++++++
Expand Down
12 changes: 12 additions & 0 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@
az containerapp replica show -n MyContainerapp -g MyResourceGroup --replica MyReplica --revision MyRevision
"""

helps['containerapp replica count'] = """
type: command
short-summary: Count of a container app's replica(s)
examples:
- name: Count replicas of a particular revision
text: |
az containerapp replica count -n MyContainerapp -g MyResourceGroup --revision MyRevision
- name: Count replicas of the latest revision
text: |
az containerapp replica count -n MyContainerapp -g MyResourceGroup
"""

# Revision Commands
helps['containerapp revision'] = """
type: group
Expand Down
1 change: 1 addition & 0 deletions src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def load_command_table(self, _):
with self.command_group('containerapp replica') as g:
g.custom_show_command('show', 'get_replica') # TODO implement the table transformer
g.custom_command('list', 'list_replicas')
g.custom_command('count', 'count_replicas', is_preview=True)
Comment thread
Juancpani marked this conversation as resolved.

with self.command_group('containerapp logs') as g:
g.custom_show_command('show', 'stream_containerapp_logs', validator=validate_ssh)
Expand Down
59 changes: 44 additions & 15 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3347,24 +3347,53 @@ def remove_dapr_component(cmd, resource_group_name, dapr_component_name, environ


def list_replicas(cmd, resource_group_name, name, revision=None):
app = ContainerAppClient.show(cmd, resource_group_name, name)
if not revision:
revision = app["properties"]["latestRevisionName"]
return ContainerAppClient.list_replicas(cmd=cmd,
resource_group_name=resource_group_name,
container_app_name=name,
revision_name=revision)

try:
app = ContainerAppClient.show(cmd, resource_group_name, name)
if not revision:
revision = app["properties"]["latestRevisionName"]
return ContainerAppClient.list_replicas(cmd=cmd,
resource_group_name=resource_group_name,
container_app_name=name,
revision_name=revision)
except Exception as e:
handle_raw_exception(e)


def count_replicas(cmd, resource_group_name, name, revision=None):

try:
app = ContainerAppClient.show(cmd, resource_group_name, name)
if not revision:
revision = safe_get(app, "properties", "latestRevisionName")
if not revision:
raise ValidationError("No revision found for containerapp.")
except Exception as e:
handle_raw_exception(e)
Comment thread
Juancpani marked this conversation as resolved.

try:
count = len(ContainerAppClient.list_replicas(cmd=cmd,
resource_group_name=resource_group_name,
container_app_name=name,
revision_name=revision))
return count
except Exception as e:
handle_raw_exception(e)


def get_replica(cmd, resource_group_name, name, replica, revision=None):
app = ContainerAppClient.show(cmd, resource_group_name, name)
if not revision:
revision = app["properties"]["latestRevisionName"]
return ContainerAppClient.get_replica(cmd=cmd,
resource_group_name=resource_group_name,
container_app_name=name,
revision_name=revision,
replica_name=replica)

try:
app = ContainerAppClient.show(cmd, resource_group_name, name)
if not revision:
revision = app["properties"]["latestRevisionName"]
return ContainerAppClient.get_replica(cmd=cmd,
resource_group_name=resource_group_name,
container_app_name=name,
revision_name=revision,
replica_name=replica)
except Exception as e:
handle_raw_exception(e)


def containerapp_ssh(cmd, resource_group_name, name, container=None, revision=None, replica=None, startup_command="sh"):
Expand Down
Loading