Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Onboard doc (#391)
Browse files Browse the repository at this point in the history
* add onboard doc

* improve doc

* improve doc2

* improve doc3

* improve doc4

* improve doc5

* improve doc6

* improve doc7

* improve doc8
  • Loading branch information
RodgeFu authored May 28, 2020
1 parent eff27cf commit 6f38991
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
66 changes: 66 additions & 0 deletions doc/how-to-generate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# How to generate code using autorest.az

There are 3 ways to use autorest.az now, pick one you prefer :)

## Through PR in [Swagger repo](https://github.com/Azure/azure-rest-api-specs)

Autorest.az has been integrated into the [swagger repo](https://github.com/Azure/azure-rest-api-specs), which means it will be triggered automatically to generate the CLI code and extension for you without any extra effort as long as the readme files are ready in the swagger repo/PR. We can help to prepare the init readme files for you as mentioned in [onboarding-guide](onboarding-guide.md), or you can also find example [here](../src/test/scenarios/attestation/configuration).

More detail can also be found in this [10-minutes video](https://msit.microsoftstream.com/video/71cea3ff-0400-a9f4-01b4-f1ea9e9b130e)

![sample image](images/codegen-in-swagger-pr.png)

## Through Docker

We have pre-prepared docker image for you to use autorest.az easily. (Please make sure [Docker](https://www.docker.com/products) has been installed. :))

1. Start docker:
* sync 'https://github.com/Azure/azure-cli-extensions.git' to {azure_cli_ext_folder} and 'https://github.com/Azure/azure-rest-api-specs.git' to {swagger_folder}
* login to Azure Container Registry and start the docker
``` bash
> az acr login --name amecodegen
> docker run -v {swagger_folder}:/home/swg -v {azure_cli_ext_folder}:/home/azext -v -it amecodegen.azurecr.io/az:2020.05.24 /bin/bash
```

2. Generate the code:
* Make sure the readme files are ready in the swagger repo. We can help to prepare the init readme files for you as mentioned in [onboarding-guide](onboarding-guide.md), or you can also find example [here](../src/test/scenarios/attestation/configuration).
* Generate the code:
``` bash
> autorest --az --azure-cli-extension-folder=/home/azext /home/swg/specification/{service_name}/resource-manager/readme.md
```

3. Run the generated command
* Generated commands are ready to use after adding the extension:
``` bash
> azdev extension add {service_name}
# your command is ready to use now
```

4. Run the generated test
* run azdev test
``` bash
> azdev test {service_name}
```

## Through autorest command directly in local
1. Make sure your environment is good to run autorest and autorest.python by following [this](https://github.com/Azure/autorest.python/wiki/Generating-with-autorest-for-python-v5.0.0).
2. sync 'https://github.com/Azure/azure-cli-extensions.git' to {azure_cli_ext_folder} and 'https://github.com/Azure/azure-rest-api-specs.git' to {swagger_folder}
3. Generate the code:
* Make sure the readme files are ready in the swagger repo. We can help to prepare the init readme files for you as mentioned in [onboarding-guide](onboarding-guide.md), or you can also find example [here](../src/test/scenarios/attestation/configuration).
* Generate the code:
``` bash
> autorest --az --azure-cli-extension-folder={azure_cli_ext_folder} {swagger_folder}/specification/{service_name}/resource-manager/readme.md
```

3. Run the generated command
* Build az extension from the generated code and load it in az
``` bash
# run this in the folder with generated code: {azure_cli_ext_folder}/src/{service_name}
> python setup.py sdist bdist_wheel
> az extension add --source={azure_cli_ext_folder}/src/{service_name}/dist/{generated .whl file}
# your az command is ready to use :)
```
4. Run the generated test
* Follow the [guidance](https://github.com/Azure/azure-cli/blob/dev/doc/authoring_tests.md) from azure-cli for running test


Binary file added doc/images/codegen-in-swagger-pr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions doc/onboarding-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Onboarding process for using Azure Cli Codegen (autorest.az)

## Step 1. Init the process

Send mail to amecodegen@microsoft.com when your swagger is ready, then we will

1. Do a quick validation on your swagger and prepare initial readme files for you
2. Have one person assigned for your service to follow up with your for any questions and support needed

## Step 2. Generate code and give it a try

1. There are 3 ways to generate code now, you can pick the one you prefer. Details can be found at [here](how-to-generate.md)
2. Try the generated command to see whether it meets your need. Further customization is supported if needed. Detail can be found at [FAQ](faq.md).

## Step 3. Run Test
1. Test will also be generated based on the examples in swagger. Run these test and make sure all of them can pass. (Refer to [here](how-to-generate.md#through-our-pre-prepared-docker) for how to run test). Customization is also supported for test if needed. Detail can be found at [here](04-scenario-test-configuration.md)
2. Add more test if the generated test is not enough. Detail can be found at [here](https://github.com/Azure/azure-cli/blob/dev/doc/authoring_tests.md)

## Step 4. Onboarding to azure-cli
1. Follow [azure-cli guidance](https://github.com/Azure/azure-cli/blob/dev/doc/onboarding_guide.md) to onboard to azure-cli
> ** we are improving the process here with Azure CLI team now
## Step Next. CLI is ready when swagger is ready
Autorest.az has been integrated into swagger PR. It means you can start reviewing your CLI code/command immediately when your swagger PR is filed for your new features/changes, so your new features/changes can have Azure CLI support very soon.

Hopefully, **your CLI is ready to merge/release when your swagger is ready to merge. :shipit: :+1:**

Check this [10-minutes video](https://msit.microsoftstream.com/video/71cea3ff-0400-a9f4-01b4-f1ea9e9b130e) for more details
> ** we are working on the process here with Azure CLI and swagger team now

0 comments on commit 6f38991

Please sign in to comment.