Awesome
Microsoft Azure CLI Dev Tools (azdev)
The azdev
tool is designed to aid new and experienced developers in contributing to Azure CLI command modules and extensions.
Getting Started Videos
3. Basics with azdev style/test/linter
4. Creating modules with azdev cli create
5. Create extensions with azdev extension create
6. Publishing extensions with azdev extension publish
Setting up your development environment
-
Install Python 3.6/3.7/3.8 from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7. Currently it's not recommended to use Python 3.9.
-
Fork and clone the repository or repositories you wish to develop for.
- For Azure CLI: https://github.com/Azure/azure-cli
- For Azure CLI Extensions: https://github.com/Azure/azure-cli-extensions
- Any other repository that you might have access to that contains CLI extensions.
After forking
azure-cli
, follow the below commands to set up:# Clone your forked repository git clone https://github.com/<your-github-name>/azure-cli.git cd azure-cli # Add the Azure/azure-cli repository as upstream git remote add upstream https://github.com/Azure/azure-cli.git git fetch upstream # Reset the default dev branch to track dev branch of Azure/azure-cli so you can use it to track the latest azure-cli code. git branch dev --set-upstream-to upstream/dev # Develop with a new branch git checkout -b <feature_branch>
You can do the same for
azure-cli-extensions
except that the default branch for it ismain
, rungit branch main --set-upstream-to upstream/main
instead.See Authenticating with GitHub from Git about caching your GitHub credentials in Git which is needed when you push the code.
-
Create a new virtual environment for Python in the root of your clone. You can do this by running:
Python 3.6+ (all platforms):
python -m venv env
or
python3 -m venv env
-
Activate the env virtual environment by running:
Windows CMD.exe:
env\Scripts\activate.bat
Windows Powershell:
env\Scripts\activate.ps1
OSX/Linux (bash):
source env/bin/activate
-
Prepare and install
azdev
If you're on Linux, install the dependency packages first by running:
For apt packages:
sudo apt install gcc python3-dev
For rpm packages:
sudo yum install gcc python3-devel
Otherwise you will have
psutil
installation issues (#269) when you setupazure-cli
later.Upgrade
pip
on all platforms:python -m pip install -U pip
Install
azdev
:pip install azdev
-
Complete setup by running:
azdev setup
This will launch the interactive setup process. You can also run with non-interactive options:
azdev setup --cli /path/to/azure-cli --repo /path/to/azure-cli-extensions
To see more non-interactive options, run
azdev setup --help
.
Authoring commands and tests
If you are building commands based on a REST API SPEC from azure-rest-api-specs, you can leverage aaz-dev-tools to generate the commands. Otherwise you can run the following commands to create a code template:
azdev extension create <extension-name>
or
azdev cli create <module-name>
If you are working on an extension, before you can run its command, you need to install the extension from the source code by running:
azdev extension add <extension-name>
Run az <command> --help
with your command groups or commands for a quick check on the command interface and help messages.
For instructions on manually writing the commands and tests, see more in
Style, linter check and testing
-
Check code style (Pylint and PEP8):
azdev style <extension-name/module-name>
-
Run static code checks of the CLI command table:
azdev linter <extension-name/module-name>
-
Record or replay CLI tests:
azdev test <extension-name/module-name>
By default, test is running in
once
mode. If there are no corresponding recording files (in yaml format), it will run live tests and generate recording files. If recording files are found, the tests will be run inplayback
mode against the recording files. You can use--live
to force a test run inlive
mode and regenerate the recording files.
Submitting a pull request to merge the code
- After committing your code locally, push it to your forked repository:
git push --set-upstream origin <feature_branch>
- Submit a PR to merge from the
feature_branch
of your repository into the default branch of Azure/azure-cli or Azure/azure-cli-extensions repositories. See Submitting Pull Requests and Publish Extensions for more details.
Reporting issues and feedback
If you encounter any bugs with the tool please file an issue in the Issues section of our GitHub repo.
Contribute Code
This project has adopted the Microsoft Open Source Code of Conduct.
For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
If you would like to become an active contributor to this project please follow the instructions provided in Microsoft Azure Projects Contribution Guidelines.
License
Azure CLI Dev Tools (azdev)
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.