-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Container App] az containerapp function: Add list and show commands for container app functions
#9155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Container App] az containerapp function: Add list and show commands for container app functions
#9155
Changes from all commits
4dc363f
a9393d8
94cf376
95e3345
e42a0f6
88ab1f6
0986024
b9c8a4b
0cf0be6
771087c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,6 +303,78 @@ def list(cls, cmd, resource_group_name, container_app_name): | |
| return policy_list | ||
|
|
||
|
|
||
| class ContainerAppFunctionsPreviewClient(): | ||
| api_version = PREVIEW_API_VERSION | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did we update |
||
|
|
||
| @classmethod | ||
| def list_functions_by_revision(cls, cmd, resource_group_name, container_app_name, revision_name): | ||
| """List all functions for a specific revision""" | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/revisions/{}/functions?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| container_app_name, | ||
| revision_name, | ||
| cls.api_version) | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "GET", request_url) | ||
| return r.json() | ||
|
|
||
| @classmethod | ||
| def get_function_by_revision(cls, cmd, resource_group_name, container_app_name, revision_name, function_name): | ||
| """Get a specific function for a specific revision""" | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/revisions/{}/functions/{}?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| container_app_name, | ||
| revision_name, | ||
| function_name, | ||
| cls.api_version) | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "GET", request_url) | ||
| return r.json() | ||
|
|
||
| @classmethod | ||
| def list_functions(cls, cmd, resource_group_name, container_app_name): | ||
| """List all functions for a container app in single revision mode""" | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/functions?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| container_app_name, | ||
| cls.api_version) | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "GET", request_url) | ||
| return r.json() | ||
|
|
||
| @classmethod | ||
| def get_function(cls, cmd, resource_group_name, container_app_name, function_name): | ||
| """Get a specific function for a container app in single revision mode""" | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/functions/{}?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| container_app_name, | ||
| function_name, | ||
| cls.api_version) | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "GET", request_url) | ||
| return r.json() | ||
|
|
||
|
|
||
| class DaprComponentResiliencyPreviewClient(): | ||
| api_version = PREVIEW_API_VERSION | ||
|
|
||
|
|
@@ -1698,3 +1770,79 @@ def remove(cls, cmd, resource_group_name, environment_name): | |
| if r.status_code == 202: | ||
| operation_url = r.headers.get(HEADER_LOCATION) | ||
| poll_results(cmd, operation_url) | ||
|
|
||
| class ContainerAppFunctionsPreviewClient: | ||
| api_version = PREVIEW_API_VERSION | ||
|
|
||
| @classmethod | ||
| def list_function_keys(cls, cmd, resource_group_name, name, function_name): | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerapps/{}/functions/{}/listkeys?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| name, | ||
| function_name, | ||
| cls.api_version) | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "POST", request_url) | ||
| return r.json() | ||
|
|
||
| @classmethod | ||
| def update_function_keys(cls, cmd, resource_group_name, name, function_name, key_name, key_value=None): | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerapps/{}/functions/{}/keys/{}?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| name, | ||
| function_name, | ||
| key_name, | ||
| cls.api_version) | ||
|
|
||
| body = {} | ||
| if key_value: | ||
| body["value"] = key_value | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(body)) | ||
| return r.json() | ||
|
|
||
| @classmethod | ||
| def list_host_keys(cls, cmd, resource_group_name, name): | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerapps/{}/host/default/listkeys?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| name, | ||
| cls.api_version) | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "POST", request_url) | ||
| return r.json() | ||
|
|
||
| @classmethod | ||
| def update_host_keys(cls, cmd, resource_group_name, name, key_type, key_name, key_value=None): | ||
| management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager | ||
| sub_id = get_subscription_id(cmd.cli_ctx) | ||
| url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerapps/{}/host/default/{}/{}?api-version={}" | ||
| request_url = url_fmt.format( | ||
| management_hostname.strip('/'), | ||
| sub_id, | ||
| resource_group_name, | ||
| name, | ||
| key_type, | ||
| key_name, | ||
| cls.api_version) | ||
|
|
||
| body = {} | ||
| if key_value: | ||
| body["value"] = key_value | ||
|
|
||
| r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(body)) | ||
| return r.json() | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -166,7 +166,6 @@ | |||||||||
| az containerapp up -n my-containerapp --image my-app:v1.0 --kind functionapp | ||||||||||
| """ | ||||||||||
|
|
||||||||||
|
|
||||||||||
| helps['containerapp replica count'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: Count of a container app's replica(s) | ||||||||||
|
|
@@ -179,6 +178,83 @@ | |||||||||
| az containerapp replica count -n my-containerapp -g MyResourceGroup | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function'] = """ | ||||||||||
| type: group | ||||||||||
| short-summary: Commands related to Azure Function on Azure Container Apps. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function list'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: List all functions in a container app or a specific revision. (pass --revisionName parameter) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Current summary seems to convey that the --revisionName parameter is mandatory, which is not true. Let's remove |
||||||||||
| long-summary: | | ||||||||||
| revisionName is required only if Container App active Revision Mode is setup in Multiple Revision Mode. (Default: Single Revision Mode) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
We have multiple and labelled revision mode, so this statement will be simpler. |
||||||||||
| Run to check activerevisionmode: az containerapp show -n my-containerapp -g MyResourceGroup --query properties.configuration.activeRevisionsMode | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| examples: | ||||||||||
| - name: List all functions in a container app. (single active revision mode) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| text: | | ||||||||||
| az containerapp function list -n my-containerapp -g MyResourceGroup | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| - name: List all functions for a specific revision | ||||||||||
| text: | | ||||||||||
| az containerapp function list -n my-containerapp -g MyResourceGroup --revision-name MyRevision | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function show'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: Show details of a specific function in a container app or a specific revision within app. (pass --revisionName parameter) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| long-summary: | | ||||||||||
| revisionName is required only if Container App active Revision Mode is setup in Multiple Revision Mode. (Default: Single Revision Mode) | ||||||||||
| Run to check activerevisionmode: az containerapp show -n my-containerapp -g MyResourceGroup --query properties.configuration.activeRevisionsMode | ||||||||||
|
Comment on lines
+205
to
+206
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment from |
||||||||||
| examples: | ||||||||||
| - name: Show details of a function in a container app. (single active revision mode) | ||||||||||
| text: | | ||||||||||
| az containerapp function show -n my-containerapp -g MyResourceGroup --function-name MyFunction | ||||||||||
| - name: Show details of a function for a specific revision | ||||||||||
| text: | | ||||||||||
| az containerapp function show -n my-containerapp -g MyResourceGroup --function-name MyFunction --revision-name MyRevision | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function list-keys'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: List function keys for a specific function in a container app. | ||||||||||
| examples: | ||||||||||
| - name: List function keys for a specific function | ||||||||||
| text: | | ||||||||||
| az containerapp function list-keys -n my-containerapp -g MyResourceGroup --revision MyContainerappRevision --function-name MyFunctionName | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function update-keys'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: Update function keys for a specific function in a container app. | ||||||||||
| examples: | ||||||||||
| - name: Update a function key for a specific function | ||||||||||
| text: | | ||||||||||
| az containerapp function update-keys -n my-containerapp -g MyResourceGroup --revision MyContainerappRevision --function-name MyFunctionName --key-name MyKeyName --key-value MyKeyValue | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function list-hostkeys'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: List host keys for a container app. | ||||||||||
| examples: | ||||||||||
| - name: List host keys for a container app | ||||||||||
| text: | | ||||||||||
| az containerapp function list-hostkeys -n my-containerapp -g MyResourceGroup --revision MyContainerappRevision | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| helps['containerapp function update-hostkeys'] = """ | ||||||||||
| type: command | ||||||||||
| short-summary: Update host keys for a container app. | ||||||||||
| examples: | ||||||||||
| - name: Update a host key for a container app with function key type | ||||||||||
| text: | | ||||||||||
| az containerapp function update-hostkeys -n my-containerapp -g MyResourceGroup --revision MyContainerappRevision --key-name MyKeyName --key-value MyKeyValue --key-type functionKeys | ||||||||||
| - name: Update a host key for a container app with master key type | ||||||||||
| text: | | ||||||||||
| az containerapp function update-hostkeys -n my-containerapp -g MyResourceGroup --revision MyContainerappRevision --key-name MyKeyName --key-value MyKeyValue --key-type masterKey | ||||||||||
| - name: Update a host key for a container app with system key type | ||||||||||
| text: | | ||||||||||
| az containerapp function update-hostkeys -n my-containerapp -g MyResourceGroup --revision MyContainerappRevision --key-name MyKeyName --key-value MyKeyValue --key-type systemKeys | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| # Environment Commands | ||||||||||
| helps['containerapp env'] = """ | ||||||||||
| type: group | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -530,3 +530,33 @@ def load_arguments(self, _): | |||||
| c.argument('termination_grace_period', options_list=['--termination-grace-period', '-t'], type=int, help="Time in seconds to drain requests during ingress shutdown. Default 500, minimum 0, maximum 3600.") | ||||||
| c.argument('request_idle_timeout', options_list=['--request-idle-timeout'], type=int, help="Timeout in minutes for idle requests. Default 4, minimum 4, maximum 30.") | ||||||
| c.argument('header_count_limit', options_list=['--header-count-limit'], type=int, help="Limit of http headers per request. Default 100, minimum 1.") | ||||||
|
|
||||||
| with self.argument_context('containerapp function') as c: | ||||||
| c.argument('resource_group_name', arg_type=resource_group_name_type, id_part=None) | ||||||
| c.argument('name', options_list=['--name', '-n'], help="The name of the Container App.") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| with self.argument_context('containerapp function list') as c: | ||||||
| c.argument('revision_name', options_list=['--revision-name', '-r'], help="The name of the revision to list functions from. It is required if container app is running in multiple active revision mode.") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parameter should just be --revision, following convention from other commands There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
|
||||||
| with self.argument_context('containerapp function show') as c: | ||||||
| c.argument('function_name', options_list=['--function-name', '-f'], help="The name of the function to show details for.") | ||||||
| c.argument('revision_name', options_list=['--revision-name', '-r'], help="The name of the revision to get the function from. It is required if container app is running in multiple active revision mode.") | ||||||
|
|
||||||
| with self.argument_context('containerapp function list-keys') as c: | ||||||
| c.argument('revision', options_list=['--revision'], help="The name of the container app revision.") | ||||||
| c.argument('function_name', options_list=['--function-name'], help="The name of the function.") | ||||||
|
|
||||||
| with self.argument_context('containerapp function update-keys') as c: | ||||||
| c.argument('revision', options_list=['--revision'], help="The name of the container app revision.") | ||||||
| c.argument('function_name', options_list=['--function-name'], help="The name of the function.") | ||||||
| c.argument('key_name', options_list=['--key-name'], help="The name of the key to update.") | ||||||
| c.argument('key_value', options_list=['--key-value'], help="The value of the key to update.") | ||||||
|
|
||||||
| with self.argument_context('containerapp function list-hostkeys') as c: | ||||||
| c.argument('revision', options_list=['--revision'], help="The name of the container app revision.") | ||||||
|
|
||||||
| with self.argument_context('containerapp function update-hostkeys') as c: | ||||||
| c.argument('revision', options_list=['--revision'], help="The name of the container app revision.") | ||||||
| c.argument('key_name', options_list=['--key-name'], help="The name of the host key to update.") | ||||||
| c.argument('key_value', options_list=['--key-value'], help="The value of the host key to update.") | ||||||
| c.argument('key_type', options_list=['--key-type'], arg_type=get_enum_type(['functionKeys', 'masterKey', 'systemKeys']), help="The type of the host key.") | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please review command from Nitesh/Deep