Skip to content

Conversation

@feliperezende-barbosa
Copy link

Related command

az apim backend

Description

Added a new subcommand for API Management. The new subcommand is az apim backend and it´s able to create, list, show, update and delete a Backend service.

Testing Guide

There are the recordings into the folder src\azure-cli\azure\cli\command_modules\apim\tests\latest\recordings and execute the command azdev test apim

History 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.

Copilot AI review requested due to automatic review settings December 22, 2025 14:22
@azure-client-tools-bot-prd
Copy link

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 22, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@azure-client-tools-bot-prd
Copy link

Validation for Breaking Change Starting...

Thanks for your contribution!

@github-actions
Copy link

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@feliperezende-barbosa feliperezende-barbosa changed the title [API Management] - New subcommand apim backend [API Management] - New subcommand az apim backend Dec 22, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Auto-Assign Auto assign by bot label Dec 22, 2025
Copy link
Contributor

Copilot AI left a 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
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
# named value operations
# backend operations

Copilot uses AI. Check for mistakes.
Comment on lines 583 to 594

# 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')])

Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
# 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 uses AI. Check for mistakes.
Comment on lines 583 to 594

# 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')])

Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
# 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 uses AI. Check for mistakes.
Comment on lines 583 to 594

# 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')])

Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
# 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 uses AI. Check for mistakes.
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)
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
setter_name='update', getter_name='get', supports_no_wait=True)
getter_name='get', supports_no_wait=True)

Copilot uses AI. Check for mistakes.
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.')
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
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.')

Copilot uses AI. Check for mistakes.
@feliperezende-barbosa
Copy link
Author

@feliperezende-barbosa please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Management az apim Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants