-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[API Management] - New subcommand az apim backend
#32569
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: dev
Are you sure you want to change the base?
[API Management] - New subcommand az apim backend
#32569
Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
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>
|
[API Management] - New subcommand apim backend[API Management] - New subcommand az apim backend
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 adds a new apim backend subcommand group to the Azure CLI API Management module, providing full CRUD operations for managing backend services. The implementation follows existing APIM command patterns and includes comprehensive test coverage. Additionally, the PR includes some maintenance fixes to existing tests (correcting test assertions and updating deprecated URLs).
- Implements five backend operations: create, show, list, update, and delete
- Adds help documentation with examples for all new commands
- Includes comprehensive integration tests covering all CRUD operations
Reviewed changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/apim/custom.py | Adds five custom functions implementing backend CRUD operations (create, delete, show, list, update) following existing APIM patterns |
| src/azure-cli/azure/cli/command_modules/apim/commands.py | Registers the new apim backend command group with appropriate command types and client factory |
| src/azure-cli/azure/cli/command_modules/apim/_params.py | Defines command-line parameters for backend operations including backend_id, url, protocol, title, description, and resource_id |
| src/azure-cli/azure/cli/command_modules/apim/_help.py | Provides help documentation and usage examples for all five backend commands |
| src/azure-cli/azure/cli/command_modules/apim/_client_factory.py | Adds backend client factory function following the existing pattern |
| src/azure-cli/azure/cli/command_modules/apim/tests/latest/test_apim_scenario.py | Adds comprehensive backend CRUD tests; also fixes existing test assertions and updates deprecated specification URLs |
| .gitignore | Adds .venv/ to ignored directories (standard Python virtual environment) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Backends operations | ||
|
|
||
| # named value operations |
Copilot
AI
Dec 22, 2025
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.
The comment says "named value operations" but this section is for backend operations. The comment should be updated to accurately reflect the operations being tested.
| # named value operations | |
| # backend operations |
|
|
||
| # backend show command | ||
| self.cmd( | ||
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | ||
| checks=[self.check('name', '{backend_id}'), | ||
| self.check('url', 'https://mybackend.com/api')]) | ||
|
|
||
| # backend update command | ||
| self.cmd( | ||
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | ||
| checks=[self.check('description', 'Updated backend description')]) | ||
|
|
Copilot
AI
Dec 22, 2025
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.
Trailing whitespace detected. Remove the trailing whitespace at the end of this line for consistency with Python code style guidelines.
| # backend show command | |
| self.cmd( | |
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | |
| checks=[self.check('name', '{backend_id}'), | |
| self.check('url', 'https://mybackend.com/api')]) | |
| # backend update command | |
| self.cmd( | |
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | |
| checks=[self.check('description', 'Updated backend description')]) | |
| # backend show command | |
| self.cmd( | |
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | |
| checks=[self.check('name', '{backend_id}'), | |
| self.check('url', 'https://mybackend.com/api')]) | |
| # backend update command | |
| self.cmd( | |
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | |
| checks=[self.check('description', 'Updated backend description')]) |
|
|
||
| # backend show command | ||
| self.cmd( | ||
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | ||
| checks=[self.check('name', '{backend_id}'), | ||
| self.check('url', 'https://mybackend.com/api')]) | ||
|
|
||
| # backend update command | ||
| self.cmd( | ||
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | ||
| checks=[self.check('description', 'Updated backend description')]) | ||
|
|
Copilot
AI
Dec 22, 2025
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.
Trailing whitespace detected. Remove the trailing whitespace at the end of this line for consistency with Python code style guidelines.
| # backend show command | |
| self.cmd( | |
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | |
| checks=[self.check('name', '{backend_id}'), | |
| self.check('url', 'https://mybackend.com/api')]) | |
| # backend update command | |
| self.cmd( | |
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | |
| checks=[self.check('description', 'Updated backend description')]) | |
| # backend show command | |
| self.cmd( | |
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | |
| checks=[self.check('name', '{backend_id}'), | |
| self.check('url', 'https://mybackend.com/api')]) | |
| # backend update command | |
| self.cmd( | |
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | |
| checks=[self.check('description', 'Updated backend description')]) |
|
|
||
| # backend show command | ||
| self.cmd( | ||
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | ||
| checks=[self.check('name', '{backend_id}'), | ||
| self.check('url', 'https://mybackend.com/api')]) | ||
|
|
||
| # backend update command | ||
| self.cmd( | ||
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | ||
| checks=[self.check('description', 'Updated backend description')]) | ||
|
|
Copilot
AI
Dec 22, 2025
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.
Trailing whitespace detected. Remove the trailing whitespace at the end of this line for consistency with Python code style guidelines.
| # backend show command | |
| self.cmd( | |
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | |
| checks=[self.check('name', '{backend_id}'), | |
| self.check('url', 'https://mybackend.com/api')]) | |
| # backend update command | |
| self.cmd( | |
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | |
| checks=[self.check('description', 'Updated backend description')]) | |
| # backend show command | |
| self.cmd( | |
| 'apim backend show -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}"', | |
| checks=[self.check('name', '{backend_id}'), | |
| self.check('url', 'https://mybackend.com/api')]) | |
| # backend update command | |
| self.cmd( | |
| 'apim backend update -g "{rg}" --service-name "{service_name}" --backend-id "{backend_id}" --description "Updated backend description" --if-match "*"', | |
| checks=[self.check('description', 'Updated backend description')]) |
| g.custom_command('list', 'apim_backend_list') | ||
| g.custom_command('delete', 'apim_backend_delete', confirmation=True, supports_no_wait=True) | ||
| g.generic_update_command('update', custom_func_name='apim_backend_update', | ||
| setter_name='update', getter_name='get', supports_no_wait=True) |
Copilot
AI
Dec 22, 2025
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.
The setter_name='update' is likely incorrect for the backend update command. Azure API Management Backend operations typically use 'create_or_update', not a separate 'update' method. This should either use 'create_or_update' explicitly or omit the setter_name parameter to use the default 'create_or_update' behavior, consistent with other APIM resources like 'apim product' (line 132) and 'apim api versionset' (line 167). The create function already uses client.backend.create_or_update (custom.py line 1183), suggesting that create_or_update is the correct method.
| setter_name='update', getter_name='get', supports_no_wait=True) | |
| getter_name='get', supports_no_wait=True) |
| schema_id = CLIArgumentType(arg_group='Schema', | ||
| help='Schema identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.') | ||
| backend_id = CLIArgumentType(arg_group='Backend', | ||
| help='Backend identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.') |
Copilot
AI
Dec 22, 2025
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.
The help text for backend_id incorrectly mentions revision support ("Non-current revision has ;rev=n as a suffix where n is the revision number"). This text appears to be copied from api_id and schema_id definitions, but backends in Azure API Management do not support revisions. The help text should be simplified to only mention that the identifier must be unique in the current API Management service instance.
| help='Backend identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.') | |
| help='Backend identifier. Must be unique in the current API Management service instance.') |
@microsoft-github-policy-service agree |
474caf9 to
ca37f6a
Compare
Related command
az apim backendDescription
Added a new subcommand for API Management. The new subcommand is
az apim backendand it´s able tocreate,list,show,updateanddeletea Backend service.Testing Guide
There are the recordings into the folder
src\azure-cli\azure\cli\command_modules\apim\tests\latest\recordingsand execute the commandazdev test apimHistory Notes
[API Management]
az apim backend: Add backend services for API Management.This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.