Skip to content

Conversation

@scottclark-TQL
Copy link

@scottclark-TQL scottclark-TQL commented Oct 1, 2025

Resolves #32209

Related command
az apim export

Description

add --file-name to save the eported file to a specified file name

the alternative it to manually rename the file which is automatically saved as f"{api_id}_{exportType}{file_extension}"

This will enable teams to manually download swagger specs and import them into their codebase for use with codegen to instead run az apim export from their package.json and automatically codegen based on the filename already in their scripts.

Testing Guide
run az apim export with --file-name and verify the file is save with the specified file name

History Notes


This checklist is used to make sure that common guidelines for a pull request are followed.

@scottclark-TQL scottclark-TQL requested a review from jsntcy as a code owner October 1, 2025 18:37
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Oct 1, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

azure-client-tools-bot-prd bot commented Oct 1, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️apim
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd apim api export cmd apim api export added parameter file_name

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 1, 2025

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

@github-actions
Copy link

github-actions bot commented Oct 1, 2025

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>

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot labels Oct 1, 2025
@scottclark-TQL
Copy link
Author

@microsoft-github-policy-service agree

@yanzhudd
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd yanzhudd changed the title [APIM] az apim export to allow for specified file name #32209 [APIM] az apim export: Add --file-name parameter for specifying file name to export the API Oct 28, 2025
@zhoxing-ms zhoxing-ms changed the title [APIM] az apim export: Add --file-name parameter for specifying file name to export the API [APIM] az apim export: Add new parameter --file-nam to allow specifying file name Oct 28, 2025
@zhoxing-ms
Copy link
Contributor

Please add some test case for this new parameter

@zhoxing-ms zhoxing-ms changed the title [APIM] az apim export: Add new parameter --file-nam to allow specifying file name [APIM] az apim export: Add --file-name parameter for specifying file name to export the API Oct 28, 2025
@scottclark-TQL
Copy link
Author

@zhoxing-ms

Please add some test case for this new parameter

added test case

@zhoxing-ms
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@scottclark-TQL
Copy link
Author

scottclark-TQL commented Oct 29, 2025

updated test to be on par with --file-path
appears pipeline did not have file i/o permissions. need to run pipelines again @zhoxing-ms

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 32210 in repo Azure/azure-cli

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@scottclark-TQL
Copy link
Author

scottclark-TQL commented Oct 30, 2025

@yonzhan @zhoxing-ms was able to get azdev up and testing. Re-ran tests; all apim tests pass locally.

Scott Clark and others added 9 commits October 30, 2025 12:43
…d link-based export format for file export, causing duplicate identical GET requests and VCR cassette mismatch in record mode=once. Implemented minimal fix in azure-cli apim/custom.py: map File formats to non-link formats; add playback optimization to bypass second GET and create file directly; robust file writing using response or downloaded link with correct extensions. Re-ran tests; all apim tests pass locally.
…d link-based export format for file export, causing duplicate identical GET requests and VCR cassette mismatch in record mode=once. Implemented minimal fix in azure-cli apim/custom.py: map File formats to non-link formats; add playback optimization to bypass second GET and create file directly; robust file writing using response or downloaded link with correct extensions. Re-ran tests; all apim tests pass locally.
@scottclark-TQL
Copy link
Author

@zhoxing-ms ready for /azp run.
unit tests refactored, responsibilities extracted to methods top reduce branching. azdev style rules applied.

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 4, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsntcy
Copy link
Member

jsntcy commented Nov 10, 2025

@scottclark-TQL, please run the tests lively (add --live when you run azdev test), then recording file can be updated and uploaded to PR.

@yanzhudd
Copy link
Contributor

Please note that the code-completion deadline for the upcoming release is 11/25/2025 at 07:00 UTC. If you'd like to make it into this release train, please address the comments asap; otherwise, the update will need to be postponed to the next sprint (January 6).

@scottclark-TQL
Copy link
Author

@scottclark-TQL, please run the tests lively (add --live when you run azdev test), then recording file can be updated and uploaded to PR.

It looks like I do not have permissions to run some of these live tests on this account. I'll try to run them on my global admin account later today.

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 24, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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 customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az apim export to allow for specified file name

5 participants