-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Containerapp] az containerapp function
: list, show, keys list/show/set, invocations summary/traces commands
#9185
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
base: main
Are you sure you want to change the base?
Conversation
…ntainerapp functions
[Containerapp] `az containerapp function`: Add function key management commands
[Container App] az containerapp function: Add list and show commands for container app functions
…ntainerapp functions
Hi @khushishah513, |
|
rule | cmd_name | rule_message | suggest_message |
---|---|---|---|
containerapp debug | cmd containerapp debug added parameter debug_command |
||
containerapp function | sub group containerapp function added |
Thank you for your contribution! We will review the pull request and get back to you soon. |
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
Release SuggestionsModule: containerapp
Notes
|
invocation_summary_query = ( | ||
f"requests | extend functionNameFromCustomDimension = tostring(customDimensions['faas.name']) " | ||
f"| where timestamp >= ago({timespan}) " | ||
f"| where cloud_RoleName =~ '{container_app_name}' " | ||
f"| where operation_Name =~ '{function_name}' or functionNameFromCustomDimension =~ '{function_name}' " | ||
f"| summarize count=count() by success" | ||
) |
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.
something for future - this will work fine in single-revision mode, but for multi-revision mode, we will need to pass revisionName as well.
- name: Set/Update a master key for a container app | ||
text: | | ||
az containerapp function keys set -n my-containerapp -g MyResourceGroup --key-type masterKey --key-name MyKeyName --key-value MyKeyValue | ||
- name: Set/Update a system key for a container app |
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 check with Shivam, if we want to add an example to rotate keys as well. Backend already supports it I think.
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.
Done
Signed-off-by: Shivam Kumar <[email protected]>
adding support for output formats and adding limit parameter to invocation traces
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.
Pull Request Overview
This PR introduces comprehensive support for Azure Functions on Azure Container Apps through new CLI commands. It adds functionality to manage functions, function keys, debug commands, and retrieve invocation data from Application Insights.
Key changes:
- Added new command groups for container app functions and function keys management
- Enhanced debug functionality with command execution capability
- Integrated Application Insights querying for function invocation monitoring
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
custom.py | Added function management commands and enhanced debug functionality with command execution |
containerapp_functions_decorator.py | New decorator classes for function listing, showing, and invocation operations |
containerapp_function_keys_decorator.py | New decorator classes for function key management operations |
containerapp_debug_command_decorator.py | New decorator for executing commands in debug containers |
commands.py | Added command group definitions and transformers for function operations |
_validators.py | Added validation functions for function apps and revision management |
_utils.py | Added utility function for replica selection |
_transformers.py | Added transformation functions for function data display and debug output |
_ssh_utils.py | Minor refactoring of debug URL generation |
_params.py | Added parameter definitions for all new function-related commands |
_help.py | Added comprehensive help documentation for new commands |
_clients.py | Added ContainerAppFunctionsPreviewClient with function and key management methods |
HISTORY.rst | Updated with new feature descriptions |
raise ValidationError(f"No replicas found for revision '{revision_name}' of container app '{container_app_name}'.") | ||
|
||
# Select a random replica | ||
replica = random.choice(replicas) |
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.
Using random selection for replica choice may lead to unpredictable behavior in production environments. Consider implementing a more deterministic selection strategy, such as choosing the first available replica or the one with the lowest load.
Copilot uses AI. Check for mistakes.
# If not valid JSON, treat as plain text and decode escape sequences | ||
decoded_output = output_str.encode().decode('unicode_escape') | ||
return decoded_output |
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.
Using decode('unicode_escape')
on untrusted input can be a security risk as it can execute escape sequences. Consider using a safer string processing approach or validate the input before decoding.
# If not valid JSON, treat as plain text and decode escape sequences | |
decoded_output = output_str.encode().decode('unicode_escape') | |
return decoded_output | |
# If not valid JSON, treat as plain text and return as-is (do not decode escape sequences) | |
return output_str |
Copilot uses AI. Check for mistakes.
0bc26da
to
41bc7ef
Compare
Adding transformers for ouput formatting and check for kind
Several minor code improvements without functionality changes
az containerapp function
az containerapp function
: list, show, keys list/show/set, invocations summary/traces commands
raise CLIError(f"No replicas found for revision '{revision_name}' of container app '{container_app_name}'.") | ||
|
||
# Select a random replica | ||
replica = random.choice(replicas) |
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.
if we have state of a replica then consider selecting latest created & healthy replica instead of random
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.
Added.
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>
locally? (pip install azdev
required)python scripts/ci/test_index.py -q
locally? (pip install wheel==0.30.0
required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.json
automatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json
.